How to combine all CSVs in a folder into one CSV

There are multiple CSV files in the input folder, and they are output together in one CSV.

import glob
import pandas as pd 

files = glob.glob('input/*.csv')
files.sort()

df_list = []
for file in files: 
    df_next = pd.read_csv(file)
    df_list.append(df_next)
df = pd.concat(df_list, ignore_index=True)
df.to_csv('output.csv')

Recommended Posts

How to combine all CSVs in a folder into one CSV
2 ways to read all csv files in a folder
How to drop Google Docs in one folder in a .txt file with python
Batch convert all xlsx files in the folder to CSV files
How to get all the possible values in a regular expression
How to make a string into an array or an array into a string in Python
How to create a git clone folder
Read all csv files in the folder
How to get a stacktrace in python
How to read CSV files in Pandas
Create a command to delete all temporary files generated in a specific folder
How to read a CSV file with Python 2/3
How to clear tuples in a list (Python)
How to embed a variable in a python string
How to create a JSON file in Python
How to implement a gradient picker in Houdini
How to notify a Discord channel in Python
How to get the files in the [Python] folder
[Python] How to draw a histogram in Matplotlib
Tensorflow, Tensorflow After all, which one (How to read Tensorflow)
How to create a Rest Api in Django
How to write a named tuple document in 2020
How to count numbers in a specific range
How to read a file in a different directory
How to Mock a Public function in Pytest
A note to load open data in CSV format into Cloudant on Bluemix
How to specify a schema in Django's database settings
How to set a shared folder with the host OS in CentOS7 on VirtualBOX
How to convert / restore a string with [] in python
How to define Decorator and Decomaker in one function
How to do zero-padding in one line with OpenCV
[Python] How to expand variables in a character string
A memorandum on how to use keras.preprocessing.image in Keras
How to use any or all to check if it is in a dictionary (Hash)
How to display DataFrame as a table in Markdown
How to turn a .py file into an .exe file
How to check in Python if one of the elements of a list is in another list
How to save a table scraped by python to csv
How to execute a command using subprocess in Python
How to reference static files in a Django project
How to read csv containing only integers in Python
[Linux] How to put your IP in a variable
How to embed multiple embeds in one message with Discord.py
How to adapt multiple machine learning libraries in one shot
How to slice a block multiple array from a multiple array in Python
How to import NoteBook as a module in Jupyter (IPython)
How to output a document in pdf format with Sphinx
A story about how to specify a relative path in python.
How to use the __call__ method in a Python class
How to check ORM behavior in one file with django
How to import a file anywhere you like in Python
How to temporarily implement a progress bar in a scripting language
How to define multiple variables in a python for statement
I tried "How to get a method decorated in Python"
How to develop in a virtual environment of Python [Memo]
How to check if a value exists in an enum
How to get the last (last) value in a list in Python
How to get all the keys and values in the dictionary
How to get a list of built-in exceptions in python
Divide a set of integers into cosets in one shot
How to import NoteBook as a module in Jupyter (IPython)