Skip to content

Instantly share code, notes, and snippets.

@scuerda
Last active September 13, 2016 17:07
Show Gist options
  • Save scuerda/a0b876d2816ee503b23695742cca3987 to your computer and use it in GitHub Desktop.
Save scuerda/a0b876d2816ee503b23695742cca3987 to your computer and use it in GitHub Desktop.
import csv
files = ['file1.csv', 'file2.csv', 'file3.csv']
rows = []
for file in files:
with open(file, 'r') as datafile:
reader = csv.DictReader(datafile)
for row in reader:
row.append(row)
with open('outfile.csv', 'w') as outfile:
writer = csv.DictWriter(outfile)
writer.writeheader(rows[0].keys())
for row in rows:
writer.writerows(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment