read.csv stops reading at row 523924 even thouhg the file has 799992 rows

♀尐吖头ヾ 提交于 2019-12-13 04:14:50

问题


Any idea why R would stop reading the file before it gets to the end?

I can open the file in excel, and it shows the full 799992. R reads only 65% of the file. I have saved the file as csv from Excel, but it did not change the number of rows R was able to read. In fact it stops reading at the exact same location every time.

I use the following command.

lem1 <- read.csv("lem1.csv", header=TRUE, sep =",")

I have the same issue on a similar data file, it only reads 57% of the file and stops "normally"


回答1:


If the data has mismatched quotes or octothorpes (or in some OSes cntrl-Z's) then abnormal termination of the file read may occur. You can sometimes get satisfactory results by resetting the defaults for quote and comment.char:

lem1 <- read.csv("lem1.csv", header=TRUE, sep =",", 
                             quote="", comment.char="")


来源:https://stackoverflow.com/questions/17955509/read-csv-stops-reading-at-row-523924-even-thouhg-the-file-has-799992-rows

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