Hi,
On Jul 24, 2009, at 11:12 AM, <mau...@alice.it> <mau...@alice.it> wrote:
I learnt from this forum to test for EOF reached with fiunction
readLines as follows:
con <- file("MyFle.txt","r")
repeat {
line <- readLines(con,n=1)
if (length(line) == 0) break
}
It works fine if I read one line at a time.
Since now I have a huge file so that it would take forever to read
one line at a time,
I wonder how to test for EOF whenreading blocks of,say, 100 lines at
a time.
Will the following work ?
con <- file("MyFle.txt","r")
repeat {
line <- readLines(con,n=100)
if (length(line) < 100) break
}
I'm guessing that by now you've already rigged up a small 10 line text
file and set n to be less than (but not a factor of) 10 to test this
and see for yourself, no?
-steve
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
______________________________________________
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.