【发布时间】:2017-08-16 06:22:04
【问题描述】:
我正在尝试使用 fread 读取一个 7.7GB 的文件,但我收到一个错误,提示它仅在文件中途停止读取:
cdr <- fread('/path/to/data.csv')
Read 1687 rows and 610989 (of 610989) columns from 4.000 GB file in 00:02:37
Warning message:
In fread("/path/to/data.csv") :
Stopped reading at empty line 1688 but text exists afterwards (discarded)
cdr <- fread('/path/to/data.csv', nrows = 2000)
Read 0.0% of 2000 rows
Error in fread("/path/to/data.csv", nrows = 2000) :
Expected sep (',') but new line or EOF ends field 500054 on line 1688 when reading data
请注意,错误消息显示文件大小为 4.000 GB,但实际上为 7.7 GB。同样的,错误信息表明文件有1687行,但实际上有3378行。
我仔细检查了,我可以确认这个文件中没有空行(thanks @MrFlick for the suggestion)。
R 在 64 位 Ubuntu 实例上运行,根据https://stackoverflow.com/a/18091755/,我检查了.Machine$sizeof.pointer 并得到了8(我相信这表明我正在以 64 位运行 R)。
【问题讨论】:
-
错误消息说输入文件中有一个空行导致它停止。是这样吗?您是否期望输入中有一个空行?
-
好问题。那是负面的;我验证文件中没有空行。
-
你可以试试
blank.lines.skip=TRUE看看是否有效 -
你是如何确认没有空行的?如果没有reproducible example,这真的是很多猜测工作。 4.00 这个数字可能只是一个巧合。
-
我在 vim 中手动检查了第 1685-1689 行。没有空行。为了安全起见,我还运行了
egrep '^$',但它也没有任何结果。
标签: r large-files