0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Pythonの同じディレクトリにあるcsvをすべて読み込む

Posted at

早速こーど!!

Pandasははいっている前提でかいてます~

import pandas as pd
import os

# CSVファイルが格納されているディレクトリのパス
directory = 'path/to/csv/directory'

# ディレクトリ内のすべてのCSVファイルを読み込む
for filename in os.listdir(directory):
    if filename.endswith('.csv'):
        file_path = os.path.join(directory, filename)
        df = pd.read_csv(file_path)
        print(f"読み込んだファイル: {filename}")
        print(df.head())  # 各ファイルの先頭5行を表示
        print("\n")
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?