2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Python】同一カラムの複数CSVファイルを1つにまとめるスクリプト

Last updated at Posted at 2023-04-21

同一カラムの複数CSVファイルを1つにまとめる際、Google Colaboratoryでつかっているスクリプトを共有します。

まとめたいCSVファイルをルートディレクトリに配置後、以下を実行すれば、同じディレクトリに出力ファイルが生成されます。

import pandas as pd
import csv
import glob
 
sample_files = glob.glob('./*.csv')
list = []
for file in sample_files:
    list.append(pd.read_csv(file))
 
df = pd.concat(list)
df.to_csv('<出力ファイル名>.csv',index=False)
2
2
2

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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?