From: Rob Biedenharn Date: 2010-07-02T22:54:47+09:00 Subject: Re: FasterCSV - Merge CSV On Jul 2, 2010, at 7:11 AM, Brian Candler wrote: > Christian Smith wrote: >> I have 3 CSVs with the same content with say 10 rows. There is a >> slight >> variation to 1 column in the data it contains. >> >> csv1 - 20 lines 10 cols >> csv2 - 52 lines 10 cols >> csv3 - 24 lines 10 cols >> >> How can I merge all 3 csvs into 1 csv using fastercsv so I have >> >> csv4 96 lines 10 cols >> >> Thanks! >> >> Seed > > Why use fastercsv? > cat csv1 csv2 csv3 >csv4 > would meet your requirement. except that you'd have headers from csv2 and csv3 (but perhaps your line counts imply no headers?) > > But if you want to use fastercsv, then open each file in turn, read it > line at a time, and output the line you just read. > -- If the files are small-ish, you can avoid a chicken-and-egg problem of the headers by reading all the input files (saving the headers from the first), then writing it all out from memory. -Rob Rob Biedenharn Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/ rab@GaslightSoftware.com http://GaslightSoftware.com/