Home > Back-end >  Trying to read files of specific date range using regex
Trying to read files of specific date range using regex

Time:09-25

I am trying to combine CSV's of a certain date range.

The csv files are named in this fashion: tvf01-value-2021-08-15 and I want to extract from date range 18th to 31st Aug 21.

I tried the code using regex:

extension = 'csv'
all_filenames = [i for i in glob.glob(r'tvf01-value-2021-08-*[18-31]{2}.{}'.format(extension))]

Any solution will be greatly appreciated. Thanks

CodePudding user response:

you can use this instead.

 all_filenames = [f'tvf01-value-2021-08-{date_range}.csv' for date_range in range(8,32)]
  • Related