gpt4 book ai didi

r - fread 从大文件中读取前 n 行

转载 作者:行者123 更新时间:2023-12-04 09:34:42 25 4
gpt4 key购买 nike

使用 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
)

最佳答案

另一种解决方法是使用 shell 命令获取前 500 行:

rdata<- fread(
cmd = paste('head -n 500', csvfile),
sep= "|", header=FALSE, col.names= colsinfile,
select= colstoselect, key = "keycolname", na.strings= c("", "NA")
)

不知道为什么 nrows不工作,虽然。

关于r - fread 从大文件中读取前 n 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52492986/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com