Author Topic: Way to automate editing multiple query items?  (Read 263 times)

Offline LostInTime

  • Associate
  • **
  • Join Date: Jul 2018
  • Posts: 4
  • Forum Citizenship: +0/-0
Way to automate editing multiple query items?
« on: 19 Jul 2018 11:51:41 am »
Hey all,

Just had a quick question. I need to edit multiple query items and change their description. I am a bit of newbie to using this software, but google hasn't been helping too much. Is there a way to easily find query items, or perhaps edit them with a script? E.g. create a script to read a csv file, find the query item and auto write the description using the info provided in the CSV?  or perhaps an internal tool I should familiarize myself with?

Thank you for reading!

EDIT: When locating the query items, there is a proprieties file "attached" to the query item. Is there anyway even to export that to something like excel or a csv sheet where I could easily edit it with a programming language like python?
« Last Edit: 19 Jul 2018 12:03:07 pm by LostInTime »

Offline Lynn

  • Statesman
  • ******
  • Join Date: Apr 2008
  • Posts: 2,682
  • Forum Citizenship: +340/-1
Re: Way to automate editing multiple query items?
« Reply #1 on: 19 Jul 2018 12:09:46 pm »
Hey all,

Just had a quick question. I need to edit multiple query items and change their description. I am a bit of newbie to using this software, but google hasn't been helping too much. Is there a way to easily find query items, or perhaps edit them with a script? E.g. create a script to read a csv file, find the query item and auto write the description using the info provided in the CSV?  or perhaps an internal tool I should familiarize myself with?

Thank you for reading!

EDIT: When locating the query items, there is a proprieties file "attached" to the query item. Is there anyway even to export that to something like excel or a csv sheet where I could easily edit it with a programming language like python?

Here are a couple links that might give you ideas:

https://www.ibm.com/developerworks/community/forums/atom/download/attachment_14197152_Bulk_Loading_Screen_Tips_into_Framework_.doc?nodeId=b8ca17f1-1b23-46cf-8ab9-2a2ed873393f

https://www.ibm.com/support/knowledgecenter/SSEP7J_10.2.1/com.ibm.swg.ba.cognos.ug_fm.10.2.1.doc/t_replaceobjectsinthemodel.html

Online CognosPaul

  • Global Moderator
  • Statesman
  • *****
  • Join Date: Jan 2009
  • Posts: 1,734
  • Forum Citizenship: +256/-1
    • Paul's Cognos Blog
Re: Way to automate editing multiple query items?
« Reply #2 on: 19 Jul 2018 12:14:26 pm »
At the end of the day the model is just an XML file. If you're any good with xpath it should be possible to write a quick script with whatever language you want.

Offline LostInTime

  • Associate
  • **
  • Join Date: Jul 2018
  • Posts: 4
  • Forum Citizenship: +0/-0
Re: Way to automate editing multiple query items?
« Reply #3 on: 19 Jul 2018 01:15:33 pm »
Here are a couple links that might give you ideas:

https://www.ibm.com/developerworks/community/forums/atom/download/attachment_14197152_Bulk_Loading_Screen_Tips_into_Framework_.doc?nodeId=b8ca17f1-1b23-46cf-8ab9-2a2ed873393f

https://www.ibm.com/support/knowledgecenter/SSEP7J_10.2.1/com.ibm.swg.ba.cognos.ug_fm.10.2.1.doc/t_replaceobjectsinthemodel.html

Thank you, I had reviewed the links and the issues I came up with are:

Link 1: Editing a bunch of query items, say like 25, is difficult in one excel sheet since everything is "disorganized" and not all relevant data is in one column, it is all over the place. Guide said I should do one by one, but that seems counterproductive and resorts back to "manual labor"

Link: Would still have to edit the files individually, and it seems I can only add a description en masse e.g. the same string for them all. Each string is unique to each value. I'd have to manually re-enter a new one.

With that being said, maybe I am missing something/doing something wrong or perhaps there are other options I could try doing?

Offline LostInTime

  • Associate
  • **
  • Join Date: Jul 2018
  • Posts: 4
  • Forum Citizenship: +0/-0
Re: Way to automate editing multiple query items?
« Reply #4 on: 19 Jul 2018 01:18:00 pm »
At the end of the day the model is just an XML file. If you're any good with xpath it should be possible to write a quick script with whatever language you want.

I would interested in accessing my model as an xml file, how would I be able to achieve this? I'm somewhat familiar with xpath and I'm sure I could figure any issues with it if they arose.

I know the model saves as a cpf file, and theres multiple xml files next to it. Do these files contain all the query items and query subjects? I have skimmed but was unable to find everything, I opened them in a text editor. Should I be using a different program?

EDIT: So wow I was able to change the description, I guess everything is there in model.xml. Had to use notepad++ instead of visual studio. Yeah going to have to play with this and learn some xpath which will be helpful. Its very disorganized but, this is a good starting point. Thanks for the suggestion
« Last Edit: 19 Jul 2018 01:37:43 pm by LostInTime »

Online CognosPaul

  • Global Moderator
  • Statesman
  • *****
  • Join Date: Jan 2009
  • Posts: 1,734
  • Forum Citizenship: +256/-1
    • Paul's Cognos Blog
Re: Way to automate editing multiple query items?
« Reply #5 on: 19 Jul 2018 03:34:40 pm »
On notepad++ you can use XML Tools to tidy the model up a bit. Once you get the basic structure down, you can write a script to do it. I don't know Python, but I understand it does support xpath, so you should be able to get it to do what you need.

Offline LostInTime

  • Associate
  • **
  • Join Date: Jul 2018
  • Posts: 4
  • Forum Citizenship: +0/-0
Re: Way to automate editing multiple query items?
« Reply #6 on: 20 Jul 2018 09:41:22 am »
Wow I am dumb.

I thought you couldn't edit the model via text editor because I tried visual studio code and it wouldn't load the entire document, only to like line 135...

Tried notepad++ and it works wonder, and just figured it out and wrote a small script. Going to test it out now and see if it works, thanks for the heads up guys :)

 


       
Twittear