Skip to content

Instantly share code, notes, and snippets.

@eherrerosj
Created December 13, 2017 09:47
Show Gist options
  • Save eherrerosj/244a11e8ea984979d7ca0e43fdf3ecbc to your computer and use it in GitHub Desktop.
Save eherrerosj/244a11e8ea984979d7ca0e43fdf3ecbc to your computer and use it in GitHub Desktop.
Load all csv files from a folder into dataframes with same names as files
import numpy as np, pandas as pd
import glob, re
dfs = { re.search('/([^/\.]*)\.csv', fn).group(1):pd.read_csv(fn) for fn in glob.glob('../input/*.csv')}
print('data frames read:{}'.format(list(dfs.keys())))
print('local variables with the same names are created.')
for k, v in dfs.items(): locals()[k] = v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment