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".

find_date(s)

Arguments

s

The filepath to look for a date in.

Details

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.

Examples


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