Skip to content

Instantly share code, notes, and snippets.

@bigsnarfdude
Last active April 24, 2020 00:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigsnarfdude/dcbf8e1e1c37f8506178831bbef5a185 to your computer and use it in GitHub Desktop.
Save bigsnarfdude/dcbf8e1e1c37f8506178831bbef5a185 to your computer and use it in GitHub Desktop.
pandas concat multiple files
import pandas as pd
from glob import glob
raw_files = sorted(glob('files*.csv'))
pd.concat((pd.read_csv(singleFile).assign(filename=singleFile) for singleFile in raw_files), ignore_index=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment