You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been getting an error when downloading the "latest" data from BITRE website.
library(ozroaddeaths)
oz_road_fatalities(source="latest")
#> Error in utils::unzip(zip_path, list = TRUE): error -103 with zipfile in unzGetCurrentFileInfo
It seems the underlying issue is in get_bitre_hard_coded() function, specifically download.file().
get_bitre_hard_coded<-function(group="fatal_crashes") {
rlang::arg_match(group, c("fatal_crashes", "fatalities"))
# Date format: "sep2024"# If current date is 2024-10, this will produce# "oct2024", "sep2024", ..., "jan2024", "dec2023", ..., "jan2023"current_month_num<- as.integer(format(Sys.time(), "%m"))
months<- tolower(month.abb[current_month_num:1])
current_year<- as.integer(format(Sys.time(), "%Y"))
past_year<-current_year-1date_replacement<- c(paste0(months, current_year),
paste0(tolower(rev(month.abb)), past_year))
# Insert dates into the link template.links<-glue::glue("https://www.bitre.gov.au/sites/default/files/documents/bitre_{group}_{date_replacement}.xlsx")
# Try links one by one until one works.temp_xlsx<- tempfile()
target_link<-NAfor (linkinlinks) {
error<- try(suppressWarnings(utils::download.file(link, quiet=TRUE, destfile=temp_xlsx)),
silent=TRUE)
if (!inherits(error, "try-error")) {
target_link<-linkbreak
}
}
# If there is no valid link, return an empty string.if (is.na(target_link)) {
return("")
} else {
return(temp_xlsx)
}
}
get_bitre_hard_coded("fatal_crashes") |>readxl::read_xlsx(sheet=2, skip=4)
#> Error in utils::unzip(zip_path, list = TRUE): error -103 with zipfile in unzGetCurrentFileInfo
This very likely could be a local issue (local network/wifi/port/etc.), so I'm curious whether others are getting this error?
I have been getting an error when downloading the "latest" data from BITRE website.
It seems the underlying issue is in
get_bitre_hard_coded()
function, specificallydownload.file()
.This very likely could be a local issue (local network/wifi/port/etc.), so I'm curious whether others are getting this error?
Created on 2024-10-29 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: