简体   繁体   中英

In Scan EOF error while reading CSV file

I am trying to read a CSV file into R. I tried:

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.

Have encountered this before. Can be very tricky. Try a specialized CSV reader.:

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

This should do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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