Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Merges n text files into a single csv, ignoring the headers in all but the first text file.
import glob
interesting_files = glob.glob("*.txt")
header_saved = False
with open('output.csv','w') as fout:
for filename in interesting_files:
with open(filename) as fin:
header = next(fin)
if not header_saved:
header_saved = True
for line in fin:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment