Downloads a .ivt (or its containing .zip) from a resolved
statcan_ivt_resolve_url() URL into the ivt cache and returns the local
.ivt path. The payload is sniffed: a .zip is unzipped, a raw IVT is kept
as-is.
Usage
statcan_ivt_download(
download_url,
key = NULL,
dest_dir = NULL,
overwrite = FALSE,
quiet = FALSE
)Arguments
- download_url
A direct-download URL (a b2020
.zipor aDownload.cfm?PID=endpoint), or a one-rowstatcan_ivt_catalogue()tibble (itsdownload_urland, by default, itscataloguenumber as the cache key are used).- key
Cache key used to name the per-table folder under the ivt cache. Optional when
download_urlis a catalogue row (defaults to the row's catalogue number).- dest_dir
Directory the
.ivtis written to. Defaults to a per-table folder under the ivt cache (ivt_cache_dir("ivt"));get_statcan_ivt()passes a temporary folder whenkeep_ivt = FALSE.- overwrite
Re-download even if a
.ivtalready exists.- quiet
Suppress the download message.
Value
Path to the local .ivt file, or NULL (invisibly, with a warning)
if the endpoint could not be reached.
Examples
# Downloads from Statistics Canada. Returns NULL with a warning if offline
# (no error), so no try() is needed.
# \donttest{
url <- statcan_ivt_resolve_url("Alternative.cfm?PID=55701&EXT=IVT")
path <- statcan_ivt_download(url, key = "97-570-X1981004", dest_dir = tempdir())
# }
