Given a filepath s, this function will look for the last correctly-parsed date in that string. Given how SafeGraph AWS file structures are, this will give you the date of those files, for example patterns_backfill/2020/12/14/21/2018/01/01 will give you "2018/01/01".




The filepath to look for a date in.


This function returns a string, not a date. You may want to send it to as.Date() or lubridate::ymd.

For backfill data, the date returned will generally be the start_date for the files. However, for new data, you will want to do as.Date(find_date(s)) - lubridate::days(9) to get the start_date.


start_date <- find_date('patterns_backfill/2020/12/14/21/2018/01/01') %>% as.Date()