Skip to main content
Question

Inserting a text line at the start of CSV

  • August 14, 2014
  • 5 replies
  • 129 views

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
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

david_r
Celebrity
  • 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
Celebrity
  • 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.