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.
Up to 100,000 records can be processed with the freeware version!
Flowheater Chart

How to add 1 line header in write side

More
13 years 4 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 or Create an account to join the conversation.

More
13 years 4 months ago #2143 by FlowHeater-Team
Replied by FlowHeater-Team on topic Re:How to add 1 line header in write side - Post(2143)
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

Please Log in or Create an account to join the conversation.

More
13 years 4 months ago #2144 by Derus
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 or Create an account to join the conversation.

Time to create page: 0.262 seconds
FlowHeater Logo

FlowHeater - The Data Specialist

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

Legal information

Support & Contact

Contact

Phone:
0951 / 9933 9792

eMail:
This email address is being protected from spambots. You need JavaScript enabled to view it.


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