Created
December 13, 2017 09:47
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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