0

I have what I think it's a simple question.

I have a file named like this: 'prec/CHIRPS/P_CHIRPS.v2.0_mm-day-1_daily_2020.01.01.tif' and you can see it has a date within.

I've used successfully the package datefinder to extract the date from that string, but now what I want to do it's actually get the format from which datefinder read that date. That means that I want an output to be '%Y.%m%.d%' so I can use it to write a file with that same date format.

This is for example to be able to use whichever format of date and whichever file name I have, extract both the date and its format, and finally rewrite something like 'this is just an example of the file name with the date 2020.01.01'.

Thanks!!

  • did you have a look at [datefinder src code](https://github.com/akoumjian/datefinder/blob/master/datefinder/constants.py)? it seem to be a bunch of `regex` tests; you might be able to extract your format here... might be tedious work though. – FObersteiner May 13 '20 at 06:46
  • Thanks for your answer. Yes I looked at the code but that's beyond my knowledges of programming and the language itself. Also looking at the source code I was able to identify that there's a parameter called `source` that gives me the string I wanted and there's another problem now, cause in the example file name, `datefinder` is also recognizing `2.0` as a date, so there's another parameter of the function `find_dates` called `strict` and if I set it to `True` it's supposed to only get complete dates, but what I get instead is nothing,so I guess it's a bug on the code but couldn't identify it – Palma Manuel May 14 '20 at 03:35

0 Answers0