read_delim throws the 'Could not guess the delimiter' error if there is only one column or data is quoted with double quotes.
hidekoji opened this issue · 3 comments
read_delim
throws the 'Could not guess the delimiter' error if there is only one column and the delim
argument is not explicitly set.
readr::read_delim("a
2022-01-01")
#> Error: Could not guess the delimiter.
#>
#> Use `vroom(delim =)` to specify one explicitly.
Created on 2023-01-13 with reprex v2.0.2
but if you explicitly specify the delim
as "," it works.
readr::read_delim("a
2022-01-01", delim = ",")
#> Rows: 1 Columns: 1
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> date (1): a
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> # A tibble: 1 × 1
#> a
#> <date>
#> 1 2022-01-01
Created on 2023-01-13 with reprex v2.0.2
readr version is 2.1.3
sessionInfo()
#> R version 4.2.1 (2022-06-23)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Big Sur ... 10.16
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> loaded via a namespace (and not attached):
#> [1] withr_2.5.0 digest_0.6.31 lifecycle_1.0.3 magrittr_2.0.3
#> [5] reprex_2.0.2 evaluate_0.19 highr_0.10 stringi_1.7.8
#> [9] rlang_1.0.6 cli_3.5.0 rstudioapi_0.14 fs_1.5.2
#> [13] vctrs_0.5.1 rmarkdown_2.19 tools_4.2.1 stringr_1.5.0
#> [17] glue_1.6.2 xfun_0.36 yaml_2.3.6 fastmap_1.1.0
#> [21] compiler_4.2.1 htmltools_0.5.4 knitr_1.41
Created on 2023-01-13 with reprex v2.0.2
Also, if the data is quoted with double quotes, it cannot detect delimiter even with the quote
argument.
df <- readr::read_delim('"Date","WWDC Page Access"
"2015-07-01",186
"2015-07-02",161', quote = '"')
#> Error: Could not guess the delimiter.
#>
#> Use `vroom(delim =)` to specify one explicitly.
Created on 2023-01-27 with reprex v2.0.2
If it's not quoted with double quotes, it can detect a delimiter.
df <- readr::read_delim('Date,WWDC Page Access
2015-07-01,186
2015-07-02,161')
#> Rows: 2 Columns: 2
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> dbl (1): WWDC Page Access
#> date (1): Date
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Created on 2023-01-27 with reprex v2.0.2
I think this is a reasonable error — it's hard for readr to know if it's a single column of data or it's failed to figure out the delimiter.