[R] test for end of file on connection

Tony Plate tplate at blackmesacapital.com
Tue May 11 17:30:05 CEST 2004


With the text of your message copied to the clipboard:

 > con <- file("clipboard", "r")
 > readLines(con, 1)
[1] "I am looking for a function to test for end-of-file on a connection."
 > readLines(con, 1)
[1] "Apparently this question was already asked a couple of years ago and"
 > readLines(con, 1)
[1] "then P. Dalgaard suggested to look at help(connections),"
 > readLines(con, 1)
[1] "help(readLines). Unfortunately, I couldn't find such a function on those"
 > readLines(con, 1)
[1] "pages, maybe I am missing something."
 > readLines(con, 1)
character(0)
 >

i.e., readLines() returns a zero length result upon reaching end of 
file.  AFAIK the other file reading functions have similar behavior.  It's 
still worth reading in detail the help for readLines().

hope this helps,

Tony Plate


At Tuesday 12:08 AM 5/11/2004, Vadim Ogranovich wrote:
>Hi,
>
>I am looking for a function to test for end-of-file on a connection.
>Apparently this question was already asked a couple of years ago and
>then P. Dalgaard suggested to look at help(connections),
>help(readLines). Unfortunately, I couldn't find such a function on those
>pages, maybe I am missing something.
>
>Did anyone figure this out?
>
>Thanks,
>Vadim
>
>
>
>
>         [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list