Skip to content
Prev 198878 / 398506 Next

Incremental ReadLines

On 11/2/2009 2:03 PM, Gene Leynes wrote:
You can open the connection before reading, then read in blocks of lines 
and process those.  You don't need to reopen it every time.  For example,

ff <- file(fname, open="rt")  # rt is read text
for (block in 1:nblocks) {
   x <- readLines(ff, n=121)
   # process this block
}
close(ff)

Duncan Murdoch