Pages

06 June, 2023

Python AttributeError: 'str' has no attribute glob

I am trying to look for a folder in a directory but I am getting the error.AttributeError: 'str' has no attribute glob Here's my code: import pandas as pd import os dir_path=('D:/CSVFILES') os.listdir(dir_path) ['0206','0306','0406'] choice_folder=input('Select a folder') file_path=os.path.join(dir_path,choice_folder) print(file_path) ['D:/CSVFILES/0306'] def ipcount_csv(file_path,filename): df=pd.read_csv(filename,on_bad_lines='skip') x=df.groupby([columnsname]).size().sort_values(ascending=False) writer=pd.Excelwriter(f'{filename}.xlsx') x.to_excel(writer,index=FaLse) writer.close() for filename in file_path.glob('*"): ipcount_csv(file_path,filename)

No comments:

Post a Comment

Thanks