简体   繁体   English

读取CSV文件时出现扫描EOF错误

[英]In Scan EOF error while reading CSV file

I am trying to read a CSV file into R. I tried: 我正在尝试将CS​​V文件读入R。我尝试过:

data <- read.csv(file="train.csv")
Warning message:
In scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :
  EOF within quoted string

But, this reads in only a small percentage of the total observations. 但是,这仅占总观测值的一小部分。 Then I tried removing quotes: 然后我尝试删除引号:

 data <- read.csv(file="train.csv",quote = "",sep = ",",header = TRUE)
Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
  more columns than column names

Since the data is text, it seems there is some issue with the delimiter. 由于数据是文本,因此分隔符似乎存在一些问题。

It is difficult to share the entire data set as it is huge. 由于数据量巨大,因此很难共享整个数据集。 I tried going to the line where the error comes, but there seems to be no non printable character. 我尝试去到错误发生的那一行,但是似乎没有不可打印的字符。 I also tried other readers like fread(), but to no avail. 我也尝试了其他阅读器,例如fread(),但无济于事。

Have encountered this before. 以前遇到过这个。 Can be very tricky. 可能非常棘手。 Try a specialized CSV reader.: 尝试使用专用的CSV阅读器。:

library(readr)
data <- read_csv(file="train.csv")

This should do it. 这应该做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM