Search
 
SCRIPT & CODE EXAMPLE
 

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')
Comment

PREVIOUS NEXT
Code Example
Python :: openpyxl get last non empty row 
Python :: tqdm parallel 
Python :: python previous answer 
Python :: python udp receive 
Python :: how to import random module in python 
Python :: q django 
Python :: parquet pyspark 
Python :: plot bounds python 
Python :: panda dataframe read csv change string to float 
Python :: python title case 
Python :: convert torch to numpy 
Python :: python lowercase 
Python :: openpyxl delete column by name 
Python :: python text fromatting rows 
Python :: how to clear a pickle file 
Python :: scrapy user agent 
Python :: how to record the steps of mouse and play the steps using python 
Python :: how to find the multiples of a number in python 
Python :: print all of dataframe 
Python :: python dedent 
Python :: pipenv 
Python :: python split on first occurrence 
Python :: reverse string in python 
Python :: import QMessageBox PyQt5 
Python :: how to sort a list in python using lambda 
Python :: remove blank spaces from a list python 
Python :: play music with time in python 
Python :: how to invert a list in python 
Python :: create virtualenv in linux python 
Python :: python input integer 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =