Search code examples
pandasglob

Pandas, Glob, use wildcard to stand for end of filename


I am programming (Pandas) around a problem where certain generated files are saved with a date attached to the file. For example: file-name_20220814.csv.

However, these files change each time they are generated, creating a new ending to the file. What is the best way to use a wildcard to stand for these file date endings?

Glob? How would I do that in the following code:

df1 = pd.read_csv('files/file-name_20220816.csv')


Solution

  • Answer provided by @mitoRibo:

    pd.read_csv(glob('files/file-name_*csv')[0])