I have a folder containing multiple files and I am looking for a file that contains only "Low" and "1 Hour". So to read all those file addresses I am using the glob library.
import glob
path = glob.glob("summary output\*.xlsx")
print(path)
output:
summary output\2030 and 2030 High RE with 1 Hour storage.xlsx
summary output\2030 and 2030 High RE with 2 Hour storage.xlsx
summary output\2030 and 2030 High RE with 4 Hour storage.xlsx
summary output\2030 and 2030 High RE with 6 Hour storage.xlsx
summary output\2030 and 2030 Low RE with 1 Hour storage.xlsx
summary output\2030 and 2030 Low RE with 2 Hour storage.xlsx
summary output\2030 and 2030 Low RE with 4 Hour storage.xlsx
summary output\2030 and 2030 Low RE with 6 Hour storage.xlsx
These are the list of files in that summary output
folder. Now I want a file which contains Low
and 1 Hour
, basically this file:
summary output\2030 and 2030 Low RE with 1 Hour storage.xlsx
so for this I wrote this:
for file in path:
if "Low" and "1 Hour" in file:
print(file)
output:
summary output\2030 and 2030 High RE with 1 Hour storage.xlsx
summary output\2030 and 2030 Low RE with 1 Hour storage.xlsx
I don't know why its taking the first file so can anyone please help?