Skip to main content
Question

Inserting a text line at the start of CSV


Forum|alt.badge.img
Hi,

 

 

I have two CSV files which I want to merge.

 

 

File A has two lines.

 

 

File B is much larger and has many lines, preceded by a header.

 

 

Effectively what I want to do is create File C from a copy of File A with File B (minus it's header) appended onto it. I don't want to alter the data in any way.

 

 

thanks

 

 

IanM

5 replies

david_r
Evangelist
  • August 14, 2014
Hi,

 

 

first of all, I'd recommend using the Text File reader/writer rather than the CSV reader/writer for this.

 

 

Then look into the Sampler to skip the header of file B. Also insert a FeatureHolder on the features from file B to prevent them from being written before all the lines from file A have been passed to the writer.

 

 

David

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • August 15, 2014
Or select relevant rows.

 

Renumber, sort and write.

 

 

Using "csv_line_number" exposed

Forum|alt.badge.img
Thanks, that's pretty much what I'm doing at the moment but the TEXT reader doesn't like a filename with .CSV so it's a little faffy ... get files, rename offline, run workspace, rename output offline

 

 

 

IanM

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • August 15, 2014
I believe the Text File reader can read any text file regardless of the extension. Try changing the filter of the Select File dialog into "All Files (*.*)".

Forum|alt.badge.img
Great. Thanks.

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings