LoginSignup
2
7

More than 3 years have passed since last update.

フォルダ内にある全てのCSVを一つのCSVにまとめる方法

Posted at

inputフォルダ内に複数のCSVファイルがあり、それを一つの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')
2
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
7