Question

Inserting a text line at the start of CSV

  • 14 August 2014
  • 5 replies
  • 17 views

Badge
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

Userlevel 4
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
Badge +3
Or select relevant rows.

 

Renumber, sort and write.

 

 

Using "csv_line_number" exposed
Badge
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
Userlevel 2
Badge +17
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 (*.*)".
Badge
Great. Thanks.

Reply