Mar-27-2020, 10:33 AM
What is
You're importing it and then you iterate over
If you want to get a list of file, use
Files
?You're importing it and then you iterate over
Files
, which is not possible, because it's a module.If you want to get a list of file, use
os.listdir
or use pathlib.Path
.from pathlib import Path my_home = Path.home() my_data = my_home / "Desktop/data" for file in my_data.glob("*.xlsx"): print(file, type(file)) wb = xl.load_workbook(file) # if openpyxl is complaining about file, convert it to a str # wb = xl.load_workbook(str(file))If openpyxl doesn't support pathlib objects, then you convert the pathlib object to a str.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!