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
If we run read_csv asking for 3 columns it gives an error if any of the files have more. I would have expected it to work by simply ignoring the columns that are not asked for.
library(readr)
packageVersion("readr")
## [1] ‘2.1.4’
fileNames <- c("test1.csv", "test2.csv")
cat("a,b,c\n1,2,3", file = fileNames[1])
cat("a,b,c,d\n11,12,13,14", file = fileNames[2])
read_csv(fileNames, col_select = 1:3, skip = 1, col_names = c("A", "B", "C"), id = "id")
## Error: Files must all have 3 columns:
## * File 2 has 4 columns
The text was updated successfully, but these errors were encountered:
That's because the column specification has to be identical when writing multiple files. If you want to handle heterogenous files, we recommend using purrr or similar, e.g. https://r4ds.hadley.nz/iteration.html#heterogeneous-data.
If we run
read_csv
asking for 3 columns it gives an error if any of the files have more. I would have expected it to work by simply ignoring the columns that are not asked for.The text was updated successfully, but these errors were encountered: