Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python merge csv files in same folder

import os, glob
import pandas as pd

os.chdir(os.path.dirname(__file__) + r"CSVs")

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 ])

os.chdir(os.path.dirname(__file__))

combined_csv.to_csv( "combined_csv.csv", index=False, encoding='utf-8-sig')
Source by github.com #
 
PREVIOUS NEXT
Tagged: #python #merge #csv #files #folder
ADD COMMENT
Topic
Name
6+5 =