user3422637
user3422637

Reputation: 4239

How do I remove the double quotes from a csv file using R before applying read.csv()?

I have a csv file in which some columns have double quotes in them. I want to remove all these double quotes in R before I apply read.csv() on this file to store the data in a data frame.

Upvotes: 3

Views: 4983

Answers (1)

Ricardo Saporta
Ricardo Saporta

Reputation: 55420

 f <- "path/to/file.csv"
 raw <- readLines(f)
 raw <- gsub("\\\"\\\"", "\"", raw)
 DAT <- read.table(text=raw)

updated to reflect Hugh's clarification below

Upvotes: 1

Related Questions