Ivan3
(Silva)
April 24, 2025, 3:23am
1
Hi mate,
I need your help. I have python 3.x and I need to find files with two variables in the path variable
path = "transaction.log." + date + "_*." + str(output1) + "*"
For example I need to find files with
transaction.log.2025-02-19_03 .sd-a703-937d.gz
transaction.log.2025-02-19_04 .sd-a703-937d.gz
What Do i need to modify in the path variable to look for these files.
Now I find all files, because i put β_*β from a date.
Regards
>>> import glob
>>> glob.glob(f'transaction.log.2025-02-19_??.sd-a703-937d.gz')
['transaction.log.2025-02-19_03.sd-a703-937d.gz', 'transaction.log.2025-02-19_04.sd-a703-937d.gz']
>>>
Ivan3
(Silva)
April 24, 2025, 1:10pm
3
Hi James
How to feed
path = βtransaction.log.β + date + β_*.β + str(output1) + β*β
where β_*.β i need to change β*β by a variable that for example look for 2 value like 03 and 04 and not all files with the same date.how would it be?
Thanks a lot James for your help!
Regards
Iβm not sure but try:
f'transaction.log.{date}_0[2-4].{str(output1)}*.gz'
The glob syntax is described here. glob β Unix style pathname pattern expansion β Python 3.13.3 documentation
Ivan3
(Silva)
April 24, 2025, 11:51pm
5
Thanks James! For your help. I can move fordward.
The option run!
1 Like