Created
September 14, 2020 15:00
-
-
Save jimdiroffii/34202257b837ca4641017a7a6037b8ec to your computer and use it in GitHub Desktop.
Combine multiple CSV files into one file
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 os | |
import glob | |
import pandas as pd | |
os.chdir("C:/Users/ishmael/Downloads/csv") | |
extension = 'csv' | |
all_filenames = [i for i in glob.glob('*.{}'.format(extension))] | |
combined_csv = pd.concat([pd.read_csv(f) for f in all_filenames ]) | |
combined_csv.to_csv( "combined_csv.csv", index=False, encoding='utf-8-sig') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment