diff --git a/DESCRIPTION b/DESCRIPTION index 2337651..0b75626 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: ohcleandat Type: Package Title: One Health Data Cleaning and Quality Checking Package -Version: 0.3.1 +Version: 0.3.2 Authors@R: c( person("Collin", "Schwantes", email = "schwantes@ecohealthalliance.org", role = c("cre", "aut"), comment = c(ORCID = "0000-0003-4014-4896")), person("Johana", "Teigen", email = "teigen@ecohealthalliance.org", role = "aut", comment = c(ORCID = "0000-0002-6209-2321")), diff --git a/NEWS.md b/NEWS.md index f42edd5..1d91398 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# ohcleandat 0.3.2 + +* Fixing issue with `download_google_drive` where search pattern is over applied. + # ohcleandat 0.3.1 * Explicitly adding `set_diff` function which was previously a hidden dependency on the {ecohealthalliance/airtabler} package diff --git a/R/download_googledrive_files.R b/R/download_googledrive_files.R index 11415fe..ca8a98d 100644 --- a/R/download_googledrive_files.R +++ b/R/download_googledrive_files.R @@ -20,7 +20,7 @@ #' download_googledrive_files( #' key_path = here::here("./key.json"), #' drive_path = "https://drive.google.com/drive/u/0/folders/asdjfnasiffas8ef7y7y89rf", -#' search_pattern = "*.xlsx", +#' search_pattern = ".*\\.xlsx", #' out_path = here::here("data/project_data/") #' ) #' } @@ -38,7 +38,7 @@ download_googledrive_files <- # recursive search of drive folder for a given file type files <- googledrive::drive_ls( path = googledrive::as_id(drive_path), - recursive = T, + recursive = TRUE, pattern = search_pattern, type = googledrive::drive_mime_type(MIME_type) ) @@ -47,27 +47,20 @@ download_googledrive_files <- files_w_ext <- files |> dplyr::mutate( extension = purrr::map_chr(drive_resource, `[[`, "fileExtension"), - path = paste0(id, ".", extension) + path = paste0(id, ".", extension), + local_path = paste({{out_path}},path,sep = "/") ) # download all files - purrr::map2( + downloaded_files <- purrr::map2_df( .x = files_w_ext$id, - .y = files_w_ext$path, - ~ googledrive::drive_download(.x, path = paste0(out_path, .y), overwrite = TRUE) + .y = files_w_ext$local_path, + ~ googledrive::drive_download(.x, .y, overwrite = TRUE) ) - # return list of downloaded files for tracking - file_list <- - list.files(path = out_path, - pattern = search_pattern, - full.names = T) + # return local file paths - # return list of downloaded files for tracking - file_list <- - list.files(path = out_path, - pattern = search_pattern, - full.names = T) + file_list <- downloaded_files$local_path return(file_list) } diff --git a/R/zzz.R b/R/zzz.R index dd2d7a8..3cb01e8 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -27,6 +27,7 @@ utils::globalVariables( "extension", "log_response_id", "n", + "path", # used in download_googledrive_files in mutate "rowid", "entry_field", "entry_field_dupe" diff --git a/man/download_googledrive_files.Rd b/man/download_googledrive_files.Rd index 3ae687a..4fea178 100644 --- a/man/download_googledrive_files.Rd +++ b/man/download_googledrive_files.Rd @@ -39,7 +39,7 @@ and is not deterministic when recursively searching. Please pay attention to wha download_googledrive_files( key_path = here::here("./key.json"), drive_path = "https://drive.google.com/drive/u/0/folders/asdjfnasiffas8ef7y7y89rf", - search_pattern = "*.xlsx", + search_pattern = ".*\\\\.xlsx", out_path = here::here("data/project_data/") ) }