2

Here is a CSV file with two character columns:

"key","value"
"a","\","

All character values are quoted by double quotes. And there is a sequence \", inside one of the values (escaped quote plus delimiter). I cannot correctly read this file neither by read.csv, nor by read_csv from readr, nor by fread from data.table.

fedyakov
  • 63
  • 9
  • Interestingly, if \" and , are separated by space than both read_csv and fread reads the file correctly. But read.csv still fails. The problem is I cannot alter content of the file and must read it as is. – fedyakov Oct 11 '16 at 18:31

1 Answers1

1

You can use readr's read_delim, which is more general than read_csv:

library(readr)

read_delim('yourfile.csv', 
           delim = ",", 
           escape_double = FALSE, 
           escape_backslash = TRUE)
Scarabee
  • 5,437
  • 5
  • 29
  • 55