Skip to main content
simply more productive

The Data Specialist

Thanks to our intuitive transformation designer, you can convert data effortlessly to a variety of formats without knowing how to program. It’s not only efficient, it’s also easy to use.
Flowheater Download

How to add 1 line header in write side

More
12 years 7 months ago #2142 by Derus
I convert an xls file to txt and I must add 1 line in output txt file to complete process. I can't found example in help file or forum. could you help me?
BR/Gilbert

Please Log in to join the conversation.

More
12 years 7 months ago #2143 by FlowHeater-Team
Replied by FlowHeater-Team on topic Re:How to add 1 line header in write side
Hi Gilbert,

I guess you want to write an additional custom header instead of filed column names?

This is possible but a bit tricky. In a further version I plan to make it easier, this will provide custom header and footer information.

The solution)
You need the .NET Script Heater and the script below.
Code:
bool bFirstLine = true; public object DoWork() { if (bFirstLine == true) { // only write additional header line for the first time bFirstLine = false; // Get the Textfile adapter on the WRITE side TextFileAdapter adapter = (TextFileAdapter)AdapterWrite; // get the filename string filename = adapter.Filename; if (File.Exists(filename)) File.Delete(filename); string header = String.Empty; // write all input parameters to a separate header line for (int i = 0; i < InValues.Length; i++) { string sTemp = (string)InValues[i].GetString(); if (sTemp == null) sTemp = String.Empty; if (header.Length > 0) header += "\r\n"; // Newline header += sTemp; } // Create the text file and write the custom header data File.WriteAllText(filename, header); } return false; // just for Filter Heater, false = no filtering }
The script writes for all input parameters you added a separate custom header line into the export file. I´ve made a little example; please have a look to the attachment. The Filter Heater in the example is just necessary for execution the script.

So that this works you have to use the option "Append to file" for the TextFile Adapter on the WRITE side.

Note: The additional headers are not writes in Test mode! The TextFile Adapter preview does not display this custom header lines. You have to execute the definition without the test mode option.


Hope this helps.

Attachment additional_header_lines.zip not found


Best wishes
Robert Stark

Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
Attachments:

Please Log in to join the conversation.

More
12 years 7 months ago #2144 by Derus
Replied by Derus on topic Re:How to add 1 line header in write side
Thanks a lot, I will try this solution who's more elegant than the one I've found!
I want use file2 = copy (file header+ file result) in batch mode.

Please Log in to join the conversation.

Time to create page: 0.280 seconds

FlowHeater - The Data Specialist

Efficient data integration and transformation with FlowHeater – the perfect solution for a seamless transfer of your data.

Rechtliches

Support & Contact

Kontaktinformation

Telefon:0951 / 99339792 E-Mail:This email address is being protected from spambots. You need JavaScript enabled to view it.

Copyright © 2009-2024 by FlowHeater GmbH. All rights reserved.