When scanning an EOF error while reading a CSV file

I am trying to read a CSV file in 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 is read only in a small percentage of the total number of observations. Then I tried to remove the 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 that there is a problem with the delimiter.

It is difficult to share the entire dataset because it is huge. I tried going to the line where the error occurs, but there seems to be no non-printable character. I also tried other readers such as fread (), but to no avail.

+5
source share
1 answer

Met earlier. It can be very difficult. Try a dedicated CSV reader.:

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

That should do it.

+5
source

All Articles