You can do something like this: con <- file("MyFle.txt","r") repeat { line <- readLines(con,n=1) if (length(line) == 0) break ParseLine(line) }
On Sun, Jul 12, 2009 at 6:20 PM, <mau...@alice.it> wrote: > I have a long text file with uneven record length and variable structure. > Therefore I have to read it line-by-line. > I found out I can open a connection to the file and read in one line at a > time. > Something like: > > con <- file("MyFle.txt","r") > while (End-Of-File) { > line <- readLines(con,n=1) > ParseLine(line) > } > > But I realized I do not know how to test for the End-Of-File condition using > R language. > I found a ghost documentation page mentioning an R built-in function > "isEof(connection)". > But such a function is not listed in R "utils" package it seems to belong to. > > I would appreciate any comment and/or suggestion. > Thank you in advance. > Maura > > > > > > > tutti i telefonini TIM! > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.