read.csv警告'引号字符串'中的EOF,但在EXCEL中成功读取 [英] read.csv warning 'EOF within quoted string' in R but successful read in EXCEL
问题描述
我尝试在此处的csv文件下载中阅读
I try to read in a csv file download from here
我使用以下代码阅读
storm_data = read.csv('./data/repdata/StormData.csv',sep=",", stringsAsFactors=F)
它返回692288个观察和一个错误消息
It returns 692288 observations and an error message
Warning message:In scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
EOF within quoted string
然后我尝试了read.table方法
Then I tried the read.table method
storm_data = read.table('./data/repdata/StormData.csv',sep=",", head=T, stringsAsFactors=F)
并返回
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 547364 did not have 37 elements
我从547364拾取相邻的行并读入一个单独的文本文件,它读取确定。所以问题不是真的存在,而是上面的某处。
I pick up the adjacent lines from 547364 and read in a separate text file and it reads OK. So the problem is not really there but somewhere above.
最后,我试着用excel读它,它读得很好(所以是我的coursera TA阅读。 csv)。它运行OK,得到903871行。
Last, I tried to read it with excel, and it reads just fine (So is my coursera TA with read.csv). It runs OK and got 903871 lines.
我完全失去了如何调试脚本。
I am totally lost on how to debug the script.
这里是我的环境信息。
我的R版本是3.1.1,Rstudio版本是0.98.1028。(32位),操作系统是赢8.1(64位)。
Here is my environment information. My R version is 3.1.1, Rstudio version is 0.98.1028.(32 bit), operating system is win 8.1(64 bit).
:我试过所有相关的方法在堆栈溢出和无工程。如果我设置quote =,行是错误的。 fread将不工作,因为我在csv文件中有\。
PS:I tried all the related method on stack overflow and none works. If I set quote="", lines are wrong. fread won't work because I got \" in the csv file.
推荐答案
我遇到了同样的错误,小时的搜索,我认为这将非常有你的一些好处。
I run into the very same error and after hours of searching, I think this will surly do you some benefits.
Sys.setlocale("LC_ALL", "English")
详情请参阅:
这篇关于read.csv警告'引号字符串'中的EOF,但在EXCEL中成功读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!