我有一个5GB的.csv文件要分析,我正在考虑通过chunk nad读取它,而不是一次处理一个块。所以试图跳过已经读过的那些行。这段代码不起作用,它只能成功读取第一个块,之后它不会读取后续迭代的垃圾值。需要帮助代码...
ReadCsvChunk <- function(ffName,chunk.num,chunk.size){
cnt = 1
nskip = 0
rCnt = chunk.size
repeat {
x <<- read.csv(file = ffName, nrows = rCnt, skip = nskip, header = T)
# ...
# analyse here
#....
nskip = nskip + chunk.size
if(cnt == chunk.num | nrow(x) < chunk.size){
break
}
cnt = cnt+1
} #repeat
}#function
ReadCsvChunk("WHO.csv",2,10) # read 2 chuck each of 10 rows