1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
+1 vote
784 views
by brandon-w-8204 (34.1k points)
I need to create a CSV file that has a header and append individual records to it. Is this possible.

2 Answers

0 votes
 
Best answer
QIE version 3.0.44 will now handle the header row on a file append and only put one header in. Just check the Append to the file option and if the destination is recieving a CSV with Headers QIE will automatically handle the header and not duplicate it.
by brandon-w-8204 (34.1k points)
edited by brandon-w-8204
+1 vote

The only way to accomplish this is to use a scheduled script on the channel to make sure the file exists with the header.

Here is the script to remove any header rows from the message before writing it to the file.

var rowContent = message.getNode('*[1]');
message = qie.createCSVMessage();
message.setNode('/', rowContent);
 
Here is a sample scheduled script to create the file with headers.
 
qie.moveFile('c:\\temp\\csvHeaderTest.csv', 'c:\\temp\\csvHeaderTest' + qie.formatDate('yyyyMMddhhmmss') + '.csv', false);
qie.writeFile('c:\\temp\\csvHeaderTest.csv', 'Header1,Header2,Header3,Header4,Header5\n', false);
by brandon-w-8204 (34.1k points)
...