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
Given a csv file with duplicated column names, when I use read_csv() to read the file with the options name_repair = "minimal" and col_select set to include the second occurrence of the repeated column, the first occurrence is read instead.
In the reprex below I've created a csv table with only two columns, both named x. When I set name_repair = "minimal" and col_select = 2, the first column is read instead. Without the option name_repair = "minimal", the second column is read correctly.
tab<- I(
"x,xa,1b,2c,3"
)
readr::read_csv(tab, col_select=2, name_repair="minimal")
#> Rows: 3 Columns: 1#> ── Column specification ────────────────────────────────────────────────────────#> Delimiter: ","#> chr (1): x#> dbl (1): x#> #> ℹ 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: 3 × 1#> x #> <chr>#> 1 a #> 2 b #> 3 creadr::read_csv(tab, col_select=2)
#> New names:#> Rows: 3 Columns: 1#> ── Column specification#> ──────────────────────────────────────────────────────── Delimiter: "," dbl#> (1): x...2#> ℹ 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.#> • `x` -> `x...1`#> • `x` -> `x...2`#> # A tibble: 3 × 1#> x...2#> <dbl>#> 1 1#> 2 2#> 3 3
The text was updated successfully, but these errors were encountered:
lucasnanni
changed the title
read_csv() reads wrong column when using col_select and name_repair = minimal in a file with duplicated column namesread_csv() reads wrong column when using col_select and name_repair = "minimal" in a file with duplicated column names
Dec 8, 2022
Given a csv file with duplicated column names, when I use
read_csv()
to read the file with the optionsname_repair = "minimal"
andcol_select
set to include the second occurrence of the repeated column, the first occurrence is read instead.In the reprex below I've created a csv table with only two columns, both named
x
. When I setname_repair = "minimal"
andcol_select = 2
, the first column is read instead. Without the optionname_repair = "minimal"
, the second column is read correctly.Created on 2022-12-07 with reprex v2.0.2
Session info
The text was updated successfully, but these errors were encountered: