
Download and extract EPC data files from ZIP archives
Source:R/odc_bulk_download.R
odc_bulk_download.RdDownloads specified ZIP files from the EPC Open Data API, extracts either certificate or recommendation CSV data, and saves it to the destination path. Handles authentication, error checking, and cleanup of temporary files.
Usage
odc_bulk_download(
file_name,
destination_path,
type = c("certificate", "recommendation"),
keep_zip = FALSE
)Arguments
- file_name
characterFile name to be downloaded (extension included) Should be a valid file name fromodc_get_file()orodc_get_file_list().- destination_path
characterDirectory path where extracted CSV file will be saved. Directory will be created if it doesn't exist.- type
characterString specifying which data type to extract from the ZIP archive. Must be either "certificate" (default) or "recommendation".- keep_zip
logicalShould the downloaded ZIP file be kept? If yes, it will be saved indestination_path. Default isFALSE(only extracted CSV is kept).
Value
Invisibly returns NULL. The function's primary purpose is the
side effect of saving extracted CSV data to disk.
Examples
if (FALSE) { # \dontrun{
# Download and extract domestic certificate data for London
odc_bulk_download(
file_name = "domestic-E08000025.zip",
destination_path = here::here("downloads"),
type = "certificate"
)
# Download and keep the ZIP file along with extracted recommendations
odc_bulk_download(
file_name = "non_domestic-E08000025.csv.zip",
destination_path = here::here("downloads"),
type = "recommendation",
keep_zip = TRUE
)
} # }