## Not run: ------------------------------------
# library(hflights)
# nrow(hflights) # Number of rows
#
# ## We create a file with no header
# input <- "hflights.csv"
# write.table(hflights,file=input,sep=",",
# row.names=FALSE,col.names=FALSE)
#
# ## Get the number of rows of each chunk
# readchunk <- make.readchunk(input,FUN=function(x){NROW(x)})
#
# a <- NULL
# while(!is.null(b <- readchunk())) {
# if(is.null(a)) {
# a <- b
# } else {
# a <- a+b
# }
# }
# all.equal(a, nrow(hflights))
#
# ## It resets automatically the file
# a <- NULL
# while(!is.null(b <- readchunk())) {
# if(is.null(a)) {
# a <- b
# } else {
# a <- a+b
# }
# }
# all.equal(a, nrow(hflights))
## ---------------------------------------------
Run the code above in your browser using DataLab