I have multiple csv file in a folder and some of them end with 'xxxxx.t01.csv'. Now what I want to do is to create a list of data frames in panda which contains all these files with '.t01.csv' ending. I tried to use fnmatch and globe2 but none of them worked. (I use python 3.7). Here are my codes:
import os, fnmatch
import pandas as pd
list_of_files = os.listdir('C:\\Users\\My_PC\\Desktop\\new folder')
for entry in list_of_files:
if fnmatch.fnmatch(entry, '*t01.csv'):
df=pd.read_csv(entry)
print(df[])
and I got this error:
then I tried with glob2 as well but I got nowhere.
import pandas as pd
import glob2
path = r''C:\\Users\\My_PC\\Desktop\\new folder''
all_files = glob2.glob(path + "*t01.csv")
for filename in all_files:
df = pd.read_csv(filename, index_col=None, header=0)
print(df)
but it will show nothing. Could someone tell me what the problem is?