Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How to join or combine multiple csv files with concatenate and export dataframe to csv format

import pandas as pd
import glob
import os
os.chdir("C:/Users/DONPECH/Desktop/PROJECTS/AIRLINE RESEARCH/RESEARCH/DATASET/flight")

# setting the path for joining multiple files
files = os.path.join("C:/Users/DONPECH/Desktop/PROJECTS/AIRLINE RESEARCH/RESEARCH/DATASET/flight", "On_Time_On_Time_Performance_2015_*.csv")

# list of merged files returned
files = glob.glob(files)

print("Resultant CSV after joining all CSV files at a particular location...");

# joining files with concat and read_csv
df = pd.concat(map(pd.read_csv, files),ignore_index=True)

#export DataFrame to CSV file
df.to_csv(r'C:UsersDONPECHDesktopPROJECTSAIRLINE RESEARCHRESEARCHDATASETflightflights.csv', index=False)
print(df)
Comment

PREVIOUS NEXT
Code Example
Python :: Joining String And Variable 
Python :: Mirror Inverse Program in python 
Python :: An error occurred while connecting: 10049: The requested address is not valid in its context.. scrapy splash 
Python :: python async get result 
Python :: Python List Note 
Python :: How to combine the output of multiple lists in python 
Python :: convert set to list python time complexity method 4 
Python :: python convert string object to int object 
Python :: python pod status phase 
Python :: python how to not allow class instance 
Python :: pyqt5 running string and clock stackoverfloww 
Python :: 0 in python 
Python :: pandas concatenation (concat) using list comprehension 
Python :: find the index of nanmax 
Python :: msg to pdf converter using python 
Python :: python created nested directory 
Python :: how to run another python file in python 
Python :: redirect user based on input with python cgi code 
Python :: how to change pi hostname in python file 
Python :: integrate label into listbox tkinter 
Python :: mylist = [“hello”, “bye”,”see ya”,”later”] phrase = mylist[1] 
Python :: how to do welcome in bubble letters in python 
Python :: pycharm shortcut to create methos 
Python :: numpy symmetrize array 
Python :: try finally return precedent 
Python :: wait until you press escape 
Python :: REST APIs with Flask and Python free download 
Python :: keras imagenet 
Python :: prettytable in python 
Python :: django filter form view 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =