[
https://issues.apache.org/jira/browse/ARROW-15260?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17469877#comment-17469877
]
Nicola Crane commented on ARROW-15260:
--------------------------------------
Yeah, that does make sense. As a short-term (and not particularly scalable)
solution, I suppose you could do something like:
{code:r}
files <- list.files(directory, recursive = TRUE, full.names = TRUE)
for(file in files){
data <- read_csv_arrow(file)
data <- mutate(data, filename = file)
write_csv_arrow(data, file = file)
}{code}
I also wonder if the code required to solve ARROW-14612 might bring us closer
to this being possible. Would be good to hear others' thoughts here.
> [R] open_dataset - add file_name as column
> ------------------------------------------
>
> Key: ARROW-15260
> URL: https://issues.apache.org/jira/browse/ARROW-15260
> Project: Apache Arrow
> Issue Type: New Feature
> Components: R
> Reporter: Martin du Toit
> Priority: Minor
>
> Hi. Is it possible to add the file_name as a column to a dataset?
> {code:r}
> ds <- open_dataset(.....)
> list_of_files <- ds$files
> {code}
> This works, but I need the file_name as a column.
> Thanks
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)