Skip to content

Commit

Permalink
Better name handling
Browse files Browse the repository at this point in the history
  • Loading branch information
fontikar committed Oct 21, 2024
1 parent 076d3df commit 7acfbbf
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions R/gbif_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ download_gbif_obs <- function(taxon,
gbif_cleaned <- suppressWarnings(gbif_process_data(gbif_obs))

# 4. Save processed data
save_data(gbif_cleaned, taxon, output_dir)
save_gbif_data(gbif_cleaned, taxon, country_code, output_dir)
}


Expand Down Expand Up @@ -206,4 +206,21 @@ gbif_process_data <- function(data){
janitor::clean_names("title")
}


save_gbif_data <- function(data, taxon, country_code = NULL, output_dir) {
if (!file.exists(file.path(output_dir))) {
dir.create(file.path(output_dir), recursive = TRUE)
}


arrow::write_parquet(x = data,
sink = file.path(
output_dir,
paste0("Living-Atlas-",
taxon,
"-",
country_code,
"-",
Sys.Date(),
".parquet")
))
}

0 comments on commit 7acfbbf

Please sign in to comment.