Skip to content
Prev 165994 / 398502 Next

Process File Line By Line Without Slurping into Object

Gundala Viswanath wrote:
Use a connection.  For example,

con <- file("filename.txt", "rt")
repeat {
    line <- readLines(con, 1)
    if (!length(line)) break
    # process the line, or change the "1" to a bigger number, and 
process the block of lines
}
close(con)

Duncan Murdoch