read.csv() warning: unable to read a csv file in R

孤街浪徒 提交于 2019-12-11 11:59:53

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!