Headers in a text file
- Feb. 14, 2010
Turbo Integrator is the ideal tool to export data or metadata to ASCII text files. To this end, we use the ASCIIOUTPUT function in the Data tab of a TI process. Nothing special for any more or less advanced TM1 user.
There is a caveat, though, if you want to add a header or footer in the text file. ASCIIOUTPUT functions append data at the end of the file. But if you write to a text file in the Prolog tab, you cannot add to it in the Metadata or Data tab. The file simply gets overwritten. The Prolog would be the best place to create a (custom) header, since it is executed before the Metadata tab and Data tab. Unlike the latter two tabs, the Prolog is executed only once, so we would end up with 1 header.
Alas, as already said, the file and the header will be deleted if we encounter ASCIIOUTPUT functions in the Metadata or Data tab to the same file.
Luckily, there is an easy workaround:
- At the end of the Prolog tab, initialize a variable:
- On top of the Data tab, increase the counter with 1 and test if it is 1:
# Wim Gielis # http://www.wimgielis.comvCounter=vCounter+1; IF(vCounter=1); ASCIIOUTPUT('filename','your custom header'); ENDIF;
Most of the time, the Data tab will contain other ASCIIOUTPUT’s to export the data from a cube view, for instance.
Extending the solution
The same technique could also be used to transfer custom errors in the Metadata or Data tab to the Server Message log, using ITEMREJECT.