The filename will be different every time, but the naming convention is the same.
Based on this solution, I want to open a filename of this example format:
20211201-095143.json
I don't want it to get confused with:
20211201-095143_metadata.json
Code:
import os
import glob
filenames = glob.glob(''.join([os.listdir(DIR), '*-*.json']))
filenames
with open(filenames[0]) as json_file:
data = json.load(json_file)
print(data)
Output:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-11-f1a73e787764> in <module>
----> 1 filenames = glob.glob(''.join([os.listdir(DIR), '*-*.json']))
2 filenames
TypeError: sequence item 0: expected str instance, list found
Please let me know if there is anything else I should clarify.