0

I have an efficient way of combining large CSV files (without reading into memory) that I want to modify so that it skips header rows. Is there a way to skip the header row, something like for line in infile if not the first line but without reading into memory?

filenames = os.listdir(localdir)
print("concatenating files %s"%(sorted((filenames))))
with open(localdir+outfile+'.csv', 'w') as outfile:
    for fname in filenames:
        with open(localdir+fname) as infile:
            for line in infile:
                outfile.write(line)
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
MichaelK
  • 15
  • 3

0 Answers0