如何在 R 中用引号字符值读取带有 \" 序列的 CSV?
How to read CSV with \", sequence inside quoted character value in R?
这是一个包含两个字符列的 CSV 文件:
"key","value"
"a","\","
所有字符值都用双引号引起来。其中一个值(转义引号加定界符)内有一个序列 \",
。我无法通过 read.csv、readr 的 read_csv 或 data.table.
的 fread 正确读取此文件
你可以使用readr
的read_delim
,它比read_csv
更通用:
library(readr)
read_delim('yourfile.csv',
delim = ",",
escape_double = FALSE,
escape_backslash = TRUE)
这是一个包含两个字符列的 CSV 文件:
"key","value"
"a","\","
所有字符值都用双引号引起来。其中一个值(转义引号加定界符)内有一个序列 \",
。我无法通过 read.csv、readr 的 read_csv 或 data.table.
你可以使用readr
的read_delim
,它比read_csv
更通用:
library(readr)
read_delim('yourfile.csv',
delim = ",",
escape_double = FALSE,
escape_backslash = TRUE)