【发布时间】:2019-02-28 18:30:36
【问题描述】:
使用fread 从一个大文件(大约 50 GB)读取前 n 行时出现错误。看起来是内存问题。我尝试使用 nrows=1000 。但没有运气。使用linux
file ok but could not memory map it. This is a 64bit process. There is probably not enough contiguous virtual memory available.
可以用read.csv 替换下面的代码并使用下面使用的所有选项吗?有帮助吗?
rdata<- fread(
file=csvfile, sep= "|", header=FALSE, col.names= colsinfile,
select= colstoselect, key = "keycolname", na.strings= c("", "NA")
, nrows= 500
)
【问题讨论】:
-
如果将
csvfile替换为paste('head -n 500', csvfile)会怎样? -
@mt1022 : 出现错误
File 'head -n 500 /csvfile' doesnt exist -
参数最终应该看起来像
input = "head -n 500 /path/to/csvfile"。请使用input参数而不是file参数来允许 shell 命令。我没有要测试的大文件。我希望这行得通。 -
@mt1022 :太棒了。当与
input一起使用时,它可以工作!.. 你应该把它作为答案
标签: r data.table fread