Created
December 22, 2016 22:33
-
-
Save ryansmccoy/c4812a204bfae7c3281179a7fcf68d1b to your computer and use it in GitHub Desktop.
Pandas Concat Folder of CSV Files
This file contains 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 | |
toglob = r'B:\TOMERGE' | |
files = glob.glob(toglob+'\*') | |
import pandas as pd | |
frame = pd.DataFrame() | |
list_ = [] | |
for file_ in files: | |
df = pd.read_csv(file_,index_col=None, header=0,encoding='utf-8', low_memory=False, error_bad_lines=False ) | |
print('imported csv file: ', file) | |
list_.append(df) | |
frame = pd.concat(list_) | |
frame.to_csv(toglob+'\combined_csv_file.csv', encoding='utf-8') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment