add bare read_from_csv_or_fetch

This commit is contained in:
2021-08-11 09:15:26 +02:00
parent 9d456bfa60
commit ecb5677703
7 changed files with 33 additions and 10 deletions
+15
View File
@@ -271,3 +271,18 @@ read_from_csv <- function(path="inst/csv/") {
is_valid_res(res)
res
}
#' @export
read_from_csv_or_fetch <- function(path="inst/") {
path <- make_directory_path(path)
res <- tryCatch(read_from_csv(str_c(path, "csv/")),
error = function(c) NULL)
if (!is.null(res)) return(res)
fetch_all(str_c(path, "records/"), create=T)
read_all(str_c(path, "records/")) %>%
repair() ->
res
write_to_csv(res, str_c(path, "csv/"), create=T)
res
}