[R] Unable to read csv files with comma in values
Amit Govil
@m|t@c@03 @end|ng |rom gm@||@com
Sat Apr 6 16:03:01 CEST 2019
Hi,
I have a bunch of csv files to read in R. I'm unable to read them correctly
because in some of the files, there is a column ("Role") which has comma in
the values.
Sample data:
User, Role, Rule, GAPId
Sam, [HadoopAnalyst, DBA, Developer], R46443
I'm trying to play with the below code but it doesnt work:
files <- list.files(pattern='.*REDUNDANT(.*).csv$')
tbl <- sapply(files, function(f) {
gsub('\\[|\\]', '"', readLines(f)) %>%
read.csv(text = ., check.names = FALSE)
}) %>%
bind_rows(.id = "id") %>%
select(id, User, Rule) %>%
distinct()
Please assist.
Thanks
[[alternative HTML version deleted]]
More information about the R-help
mailing list