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

vroom does not work on list of connections #509

Closed
bart1 opened this issue Sep 12, 2023 · 1 comment · Fixed by #514
Closed

vroom does not work on list of connections #509

bart1 opened this issue Sep 12, 2023 · 1 comment · Fixed by #514

Comments

@bart1
Copy link
Contributor

bart1 commented Sep 12, 2023

I was following this example from the vignette but it seems vroom does not accept a list of connection I get the following message

> vroom::vroom(list(file("file1.csv"), file("file2.csv")))
Error in enc2utf8(path) : argument is not a character vector

vroom/vignettes/vroom.Rmd

Lines 113 to 118 in 89b6aac

```{r}
read_all_zip <- function(file, ...) {
filenames <- unzip(file, list = TRUE)$Name
vroom(purrr::map(filenames, ~ unz(file, .x)), ...)
}
```

@bairdj
Copy link
Contributor

bairdj commented Sep 15, 2023

Reprex for this issue

library(vroom)
#> Warning: package 'vroom' was built under R version 4.2.3
library(purrr)

archive_path <- "test_archive.zip"
connections <- map(unzip(archive_path, list = TRUE)$Name, ~ unz(archive_path, .x))

print(connections)
#> [[1]]
#> A connection with                                           
#> description "test_archive.zip:file_001.csv"
#> class       "unz"                          

#> mode        "r"                            
#> text        "text"                         
#> opened      "closed"                       
#> can read    "yes"                          
#> can write   "yes"                          
#> 
#> [[2]]
#> A connection with                                           
#> description "test_archive.zip:file_002.csv"
#> class       "unz"                          
#> mode        "r"                            
#> text        "text"                         
#> opened      "closed"                       
#> can read    "yes"                          
#> can write   "yes"

vroom(connections)
#> Error in enc2utf8(path): argument is not a character vector

Created on 2023-09-15 with reprex v2.0.2

File: test_archive.zip

I believe the issue is that the check for connection objects in standardise_path does not handle a list of connections, only a single object https:/tidyverse/vroom/blob/89b6aac8c9c07981a52c28251578deca11810ebd/R/path.R#L29C12-L29C12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants