Created
May 18, 2017 16:44
-
-
Save brockthebear/a3f384304fbb8667627e93e53af86632 to your computer and use it in GitHub Desktop.
Combine multiple CSVs into one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
files = glob.glob("*.csv") | |
header_saved = False | |
with open('output.csv', 'w') as fout: | |
for file in files: | |
with open(file) as fin: | |
header = next(fin) | |
if not header_saved: | |
fout.write(header) | |
header_saved = True | |
for line in fin: | |
fout.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment