我在R中读取csv时遇到问题。我使用
logfile <- read.csv(path
,header=TRUE
,dec="."
,quote="""
, sep=","
,colClasses=c("character","character"),
stringsAsFactors = FALSE #?EOF problem
)
读取csv。该命令在csv的中间部分中断,并显示消息:
Warning message:
In scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
EOF within quoted string
由于文件中存在一些多行条目,禁用引用无效。
以下是一个示例文件:http://www.file-upload.net/download-8867381/RAS_ERROR_ascii_reproducible.csv.html
我该如何解决这个问题?
如果使用data.table
的fread
,它将抛出一个错误,但警告您在文件末尾追加一行新行。如果按照此操作并在文件末尾附加"rn"
,则fread
将正确读取文件(即使使用默认参数(。