I want to read csv files from a folder based on condition. I just want to read csv files that include “1441” in the filename. I used fnmatch, but it doesn’t work. Can anyone help?
path_to_parent = r"C:\Users\Desktop\books/chapter_1"
for csv_file in os.listdir(path_to_parent):
if fnmatch.fnmatch(csv_file,'1441'):
my_file = pd.read_csv(path_to_parent+csv_file)
else:
print('error')