Jan-13-2022, 08:59 PM
(This post was last modified: Jan-13-2022, 08:59 PM by randolphoralph.)
(Jan-13-2022, 07:57 PM)snippsat Wrote:(Jan-13-2022, 07:09 PM)randolphoralph Wrote: The directory would only contain one file, and the file would have a date in the file name.Can use glob or also pathlib has glob build in.
Example
import pandas as pd from pathlib import Path dest = r'.' for path in Path(dest).rglob('output_*_result.xlsx'): if path.is_file(): print(path) df = pd.read_excel(path) print(df)Now will this match any number.
So in my test one file with these two names read fine.
output_123_result.xlsx output_99999_result.xlsxAs it's one file should get away with not specify sheet name.
I added from pathlib import Path, but get an error stating ImportError: cannot import name 'path' from 'pathlib'. Does it matter that I am working within Windows?