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

import() works for URLs but not import_list() #294

Closed
billdenney opened this issue Feb 25, 2022 · 1 comment
Closed

import() works for URLs but not import_list() #294

billdenney opened this issue Feb 25, 2022 · 1 comment
Assignees

Comments

@billdenney
Copy link
Contributor

This is somewhere between a bug and a feature request (probably closer to a feature request).

When trying to use import_list() on a URL with a .xls file, it fails due to "path does not exist", but it works for import(). I think that it would be preferable for import() and import_list() to always work for URLs. But, maybe this is an issue that should be brought up with the underlying package which is doing the loading.

url <- "https://evs.nci.nih.gov/ftp1/CDISC/SDTM/SDTM%20Terminology.xls"
d_raw <- rio::import(url)
#> New names:
#> * `` -> ...2
d_raw <- rio::import_list(url)
#> Error: `path` does not exist: 'https://evs.nci.nih.gov/ftp1/CDISC/SDTM/SDTM%20Terminology.xls'

Created on 2022-02-25 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value
#>  version  R version 4.1.2 (2021-11-01)
#>  os       Windows 10 x64 (build 19043)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United States.1252
#>  ctype    English_United States.1252
#>  tz       America/New_York
#>  date     2022-02-25
#>  pandoc   2.16.1 @ C:/Program Files/RStudio/bin/quarto/bin/ (via rmarkdown)
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version date (UTC) lib source
#>  backports     1.4.1   2021-12-13 [1] CRAN (R 4.1.2)
#>  cellranger    1.1.0   2016-07-27 [1] CRAN (R 4.1.0)
#>  cli           3.1.1   2022-01-20 [1] CRAN (R 4.1.2)
#>  crayon        1.5.0   2022-02-14 [1] CRAN (R 4.1.2)
#>  curl          4.3.2   2021-06-23 [1] CRAN (R 4.1.0)
#>  data.table    1.14.2  2021-09-27 [1] CRAN (R 4.1.1)
#>  digest        0.6.29  2021-12-01 [1] CRAN (R 4.1.2)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.0)
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 4.1.0)
#>  fansi         1.0.2   2022-01-14 [1] CRAN (R 4.1.2)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.1.0)
#>  forcats       0.5.1   2021-01-27 [1] CRAN (R 4.1.0)
#>  foreign       0.8-82  2022-01-13 [1] CRAN (R 4.1.2)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.1.2)
#>  glue          1.6.1   2022-01-22 [1] CRAN (R 4.1.2)
#>  haven         2.4.3   2021-08-04 [1] CRAN (R 4.1.1)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.1.0)
#>  hms           1.1.1   2021-09-26 [1] CRAN (R 4.1.1)
#>  htmltools     0.5.2   2021-08-25 [1] CRAN (R 4.1.1)
#>  knitr         1.37    2021-12-16 [1] CRAN (R 4.1.2)
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.1.1)
#>  magrittr      2.0.2   2022-01-26 [1] CRAN (R 4.1.2)
#>  openxlsx      4.2.5   2021-12-14 [1] CRAN (R 4.1.2)
#>  pillar        1.7.0   2022-02-01 [1] CRAN (R 4.1.2)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.0)
#>  purrr         0.3.4   2020-04-17 [1] CRAN (R 4.1.0)
#>  R.cache       0.15.0  2021-04-30 [1] CRAN (R 4.1.0)
#>  R.methodsS3   1.8.1   2020-08-26 [1] CRAN (R 4.1.0)
#>  R.oo          1.24.0  2020-08-26 [1] CRAN (R 4.1.0)
#>  R.utils       2.11.0  2021-09-26 [1] CRAN (R 4.1.1)
#>  Rcpp          1.0.8   2022-01-13 [1] CRAN (R 4.1.2)
#>  readxl        1.3.1   2019-03-13 [1] CRAN (R 4.1.0)
#>  reprex        2.0.1   2021-08-05 [1] CRAN (R 4.1.1)
#>  rio           0.5.29  2021-11-22 [1] CRAN (R 4.1.2)
#>  rlang         1.0.1   2022-02-03 [1] CRAN (R 4.1.2)
#>  rmarkdown     2.11    2021-09-14 [1] CRAN (R 4.1.1)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.1.0)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.1.2)
#>  stringi       1.7.6   2021-11-29 [1] CRAN (R 4.1.2)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.1.0)
#>  styler        1.6.2   2021-09-23 [1] CRAN (R 4.1.1)
#>  tibble        3.1.6   2021-11-07 [1] CRAN (R 4.1.2)
#>  utf8          1.2.2   2021-07-24 [1] CRAN (R 4.1.0)
#>  vctrs         0.3.8   2021-04-29 [1] CRAN (R 4.1.0)
#>  withr         2.4.3   2021-11-30 [1] CRAN (R 4.1.2)
#>  xfun          0.29    2021-12-14 [1] CRAN (R 4.1.2)
#>  yaml          2.2.2   2022-01-25 [1] CRAN (R 4.1.2)
#>  zip           2.2.0   2021-05-31 [1] CRAN (R 4.1.0)
#> 
#>  [1] C:/Users/Bill Denney/Documents/R/win-library/4.1
#>  [2] C:/Program Files/R/R-4.1.2/library
#> 
#> ------------------------------------------------------------------------------
@chainsawriot
Copy link
Collaborator

@billdenney

This actually works.

url <- c("https://evs.nci.nih.gov/ftp1/CDISC/SDTM/SDTM%20Terminology.xls", "https://evs.nci.nih.gov/ftp1/CDISC/SDTM/SDTM%20Terminology.xls")
import_list(url)

The problem is this block (when file is of length 1), which is not URL sensitive.

rio/R/import_list.R

Lines 73 to 83 in 067a0ae

} else if (get_ext(file) %in% c("xls","xlsx")) {
.check_pkg_availability("readxl")
whichnames <- readxl::excel_sheets(path = file)
if (missing(which)) {
which <- seq_along(whichnames)
names(which) <- whichnames
} else if (is.character(which)) {
whichnames <- which
} else {
whichnames <- whichnames[which]
}

I will fix this.

@chainsawriot chainsawriot self-assigned this Sep 3, 2023
chainsawriot added a commit that referenced this issue Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants