Page 1 of 1

Concatenate data using ASCIIOUTPUT

Posted: Thu Mar 26, 2015 4:21 pm
by tm1_user
Hi All,

I have a written a TI Process which generates data from the Cube and writes to a file using ASCIIOUTPUT.

In this TI Process, the text is generated in PROLOG tab and DATA tab.
I want all the text to be written into a single file (Prolog tab generated Data and then Data tab generated Data).

If I use same file name in Prolog and Data tabs, the Prolog generated data is overwritten by Data tab generated data.

Is there any method to append the data from both tabs.

Cheers

Re: Concatenate data using ASCIIOUTPUT

Posted: Thu Mar 26, 2015 4:28 pm
by tomok
tm1_user wrote:Hi All,

I have a written a TI Process which generates data from the Cube and writes to a file using ASCIIOUTPUT.

In this TI Process, the text is generated in PROLOG tab and DATA tab.
I want all the text to be written into a single file (Prolog tab generated Data and then Data tab generated Data).

If I use same file name in Prolog and Data tabs, the Prolog generated data is overwritten by Data tab generated data.

Is there any method to append the data from both tabs.

Cheers
Let me give you a tip. Just blindly asking questions that can be easily answered by either reading the docs or doing a search on this forum is not going to curry you much favor with the contributors of this group. In your case a quick search of this forum will turn up a number of posts about this very topic. This question get's asked, at some point, by almost every new developer.

Re: Concatenate data using ASCIIOUTPUT

Posted: Thu Mar 26, 2015 5:05 pm
by jim wood
By searching concatenate file you get this......
http://www.tm1forum.com/viewtopic.php?f=19&t=516

Re: Concatenate data using ASCIIOUTPUT

Posted: Thu Mar 26, 2015 5:25 pm
by tomok
I'm pretty sure this is what he is looking for:

http://www.tm1forum.com/viewtopic.php?f=3&t=3245

Re: Concatenate data using ASCIIOUTPUT

Posted: Thu Mar 26, 2015 5:52 pm
by jim wood
tomok wrote:I'm pretty sure this is what he is looking for:

http://www.tm1forum.com/viewtopic.php?f=3&t=3245
I'm not sure how you got to headings? It sounded to me like he's trying to concatenate text generated from 2 different tabs, which as the link I specified said, you can only do this using a dos command to append 2 files. Or have I gone mad??????

Re: Concatenate data using ASCIIOUTPUT

Posted: Thu Mar 26, 2015 7:04 pm
by declanr
jim wood wrote:It sounded to me like he's trying to concatenate text generated from 2 different tabs, which as the link I specified said, you can only do this using a dos command to append 2 files. Or have I gone mad??????
Or my personal favourite of doing 2 bulk inserts to a sql table and then exporting the lot into a new file; sounds like overkill but after bitter experience I have now ended up going down the route of putting everything out to SQL with a timestamp at every possible opportunity so that I can "keep an eye on things"... even when only a CSV extract is needed I will always throw it into SQL as well; especially if the extract is going elsewhere afterwards - as you inevitably get someone saying "You didn't give us that number; TM1 must be wrong" when it turns out they just decided to fudge the extract and "forgot" all about it when pulled up on the fact.

Am I sounding cynical today? :roll:

Re: Concatenate data using ASCIIOUTPUT

Posted: Thu Mar 26, 2015 7:24 pm
by jim wood
It's a bit anal I'll give that, but it's not a bad plan. Better safe than sorry.

Re: Concatenate data using ASCIIOUTPUT

Posted: Thu Mar 26, 2015 7:28 pm
by tomok
jim wood wrote:
tomok wrote:I'm pretty sure this is what he is looking for:

http://www.tm1forum.com/viewtopic.php?f=3&t=3245
I'm not sure how you got to headings? It sounded to me like he's trying to concatenate text generated from 2 different tabs, which as the link I specified said, you can only do this using a dos command to append 2 files. Or have I gone mad??????
Headings? It doesn't really matter what you want to write but if you want to write a line(s) to a file on the Prolog and then continue writing to the same file in the Data tab it's quite simple:

1) Add a counter variable.
2) In the prolog set it to 0
3) Move the ASCIIOutput code you previously wanted to write in the Prolog tab to the Data tab, put it at the top and then have an IF to execute it only when the counter is 0
4) Have your regular Data tab ASCIIOutputs
5) Increment the counter by 1

This technique will work regardless of what's in the actual ASCIIOutputs. Everything will go in one file. I use it all the time. If you have more than one line to write out in the Prolog then just up your counter and put those extra lines inside the IF statement at the top of the Data tab.

Re: Concatenate data using ASCIIOUTPUT

Posted: Thu Mar 26, 2015 8:35 pm
by jim wood
Tomok,

If you click on the link you posted it talks about how to set a counter to make sure the headers in a file are written once. It has nothing to do with merging files, hence my question,

Jim.

Re: Concatenate data using ASCIIOUTPUT

Posted: Thu Mar 26, 2015 10:35 pm
by tomok
jim wood wrote:Tomok,

If you click on the link you posted it talks about how to set a counter to make sure the headers in a file are written once. It has nothing to do with merging files, hence my question,

Jim.
If you read the original post that's exactly what he's talking about, the fact that if you write to a file in the Prolog and then write to the SAME FILE in the Data tab then the stuff you wrote in the Prolog disappears. Hence my link that talks about how you can get around that. Merging the output of two separate files AFTER a TI finishes is an entirely different conversation.

Re: Concatenate data using ASCIIOUTPUT

Posted: Fri Mar 27, 2015 8:50 am
by tm1_user
tomok wrote:
jim wood wrote:
tomok wrote:I'm pretty sure this is what he is looking for:

http://www.tm1forum.com/viewtopic.php?f=3&t=3245
I'm not sure how you got to headings? It sounded to me like he's trying to concatenate text generated from 2 different tabs, which as the link I specified said, you can only do this using a dos command to append 2 files. Or have I gone mad??????
Headings? It doesn't really matter what you want to write but if you want to write a line(s) to a file on the Prolog and then continue writing to the same file in the Data tab it's quite simple:

1) Add a counter variable.
2) In the prolog set it to 0
3) Move the ASCIIOutput code you previously wanted to write in the Prolog tab to the Data tab, put it at the top and then have an IF to execute it only when the counter is 0
4) Have your regular Data tab ASCIIOutputs
5) Increment the counter by 1

This technique will work regardless of what's in the actual ASCIIOutputs. Everything will go in one file. I use it all the time. If you have more than one line to write out in the Prolog then just up your counter and put those extra lines inside the IF statement at the top of the Data tab.

Thank you all for the responses. There are no headings required on the output. Its only the data from the cube.

@Tomok, I have followed the above steps, it simply worked!! :)