You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Nicola Crane (Jira)" <ji...@apache.org> on 2022/10/14 11:39:00 UTC
[jira] [Created] (ARROW-18049) [R] Support column renaming in col_select argument to file reading functions
Nicola Crane created ARROW-18049:
------------------------------------
Summary: [R] Support column renaming in col_select argument to file reading functions
Key: ARROW-18049
URL: https://issues.apache.org/jira/browse/ARROW-18049
Project: Apache Arrow
Issue Type: Improvement
Components: R
Reporter: Nicola Crane
We should support the ability to rename columns when reading in data via the CSV/Parquet/Feather/JSON file readers.
We currently have an argument {{col_select}}, which allows users to choose which columns to read in, but renaming doesn't work.
To implement this, we'd need to check if any columns have been renamed by {{col_select}} and then updating the schema of the object being returned once the file has been read.
{code:r}
library(readr)
library(arrow)
readr::read_csv(readr_example("mtcars.csv"), col_select = c(not_hp = hp))
#> # A tibble: 32 × 1
#> not_hp
#> <dbl>
#> 1 110
#> 2 110
#> 3 93
#> 4 110
#> 5 175
#> 6 105
#> 7 245
#> 8 62
#> 9 95
#> 10 123
#> # … with 22 more rows
arrow::read_csv_arrow(readr_example("mtcars.csv"), col_select = c(not_hp = hp))
#> # A tibble: 32 × 1
#> hp
#> <int>
#> 1 110
#> 2 110
#> 3 93
#> 4 110
#> 5 175
#> 6 105
#> 7 245
#> 8 62
#> 9 95
#> 10 123
#> # … with 22 more rows
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)