Manu
Manu

Reputation: 11

Can we Provide a file pattern as input in pandas read_csv

My filename is Manu_Nwrk_Dump-2019_7_15-11_2_58_99.csv where the text after Dump is date and other junk numbers (not fixed). Is it possible to provide a file pattern as Manu_Nwrk_Dump*.csv in pandas read_csv input

Tried passing Manu_Nwrk_Dump*.csv which didnt work

Upvotes: 0

Views: 860

Answers (1)

Manu
Manu

Reputation: 11

The issue was resolved by using glob.

from glob import glob
for f in glob('Manu_Nwrk_Dump*.csv'):
    my_data = pd.read_csv(f,sep='\t', index_col=False)

Upvotes: 1

Related Questions