Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use old readr on windows #206

Merged
merged 2 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/dl.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ dl_stats19 = function(year = NULL,
utils::download.file(zip_url, destfile = destfile, quiet = silent)
}
if(is_zip_file) {
f = file.path(destfile, utils::unzip(destfile, list = TRUE)$Name)
f2 = file.path(destfile, utils::unzip(destfile, list = TRUE)$Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonable object renaming, sorry for the terse object names, and having thought about it more explicit and longer names would probably better - only issue being when you go over 80 characters on a line. FYI this would not be allowed if we used Rust and the clippy code checking tool. Heads up @dabreegster in case it's of interest, this is deep in the codebase that downloads, reads and cleans the STATS19 crash data for the UK.

utils::unzip(destfile, exdir = file.path(data_dir, exdir))
if (isFALSE(silent)) {
message("Data saved at ", sub(".zip", "",f))
message("Data saved at ", sub(".zip", "", f2))
}
} else if (isFALSE(silent)) {
message("Data saved at ", destfile)
Expand Down
12 changes: 12 additions & 0 deletions R/read.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ read_accidents = function(year = NULL,
data_dir = get_data_directory(),
format = TRUE,
silent = FALSE) {
# Set the local edition for readr.
# See https://github.com/ropensci/stats19/issues/205
if (.Platform$OS.type == "windows" && utils::packageVersion("readr") >= "2.0.0") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimising the impact of the change 👍

readr::local_edition(1)
}

path = check_input_file(
filename = filename,
type = "accidents",
Expand Down Expand Up @@ -163,6 +169,12 @@ check_input_file = function(filename = NULL,
# path = file.path(get_data_directory(), f)
# read_ve_ca(path)
read_ve_ca = function(path) {
# Set the local edition for readr.
# See https://github.com/ropensci/stats19/issues/205
if (.Platform$OS.type == "windows" && utils::packageVersion("readr") >= "2.0.0") {
readr::local_edition(1)
}
layik marked this conversation as resolved.
Show resolved Hide resolved

h = utils::read.csv(path, nrows = 1)
if(grepl("Accident_Index", names(h)[1])) {
readr::read_csv(path, col_types = readr::cols(
Expand Down