I have a file whose name will get updated daily, but the name will always match some simple pattern e.g. it will always begin with 'report' e.g. report 1 A 2X.csv
How do I open the file on any given day, not knowing what its name will be but knowing the pattern and knowing there will only ever be one file in the folder that matches?
If I define:
pattern = 'report'
then how do I combine os.listdir('.')
and str.startswith(pattern)
with open()
to achieve this?