问题
I was trying to read a csv file in R and read.csv gives me a warning and consequently stops reading from there on. I think it's something related to an extra quote being there. How can I resolve this?
(csv file put on a public share below for access)
> scoresdf = read.csv('http://aftabubuntu.cloudapp.net/trainDataEnglish.csv')
Warning message:
In scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
EOF within quoted string
回答1:
I got the same error on read.csv
. I managed to get it working with the rio
package:
library(rio)
dat <- import("http://aftabubuntu.cloudapp.net/trainDataEnglish.csv")
and the readr
package:
library(readr)
dat <- read_csv("http://aftabubuntu.cloudapp.net/trainDataEnglish.csv")
and the data.table
package:
library(data.table)
dat <- fread("http://aftabubuntu.cloudapp.net/trainDataEnglish.csv")
回答2:
Try
url <- 'http://aftabubuntu.cloudapp.net/trainDataEnglish.csv'
scoresdf = read.csv(url,quote="")
As you suspected, there is indeed an embedded quotation mark somewhere within your document.
来源:https://stackoverflow.com/questions/29617582/read-csv-warning-unable-to-read-a-csv-file-in-r