Skip to content
Back to formatted view

Raw Message

Message-ID: <k9jvavcjn05ooo68br61sk8i9dsj9moaas@4ax.com>
Date: 2003-04-30T13:19:20Z
From: Duncan Murdoch
Subject: Scanning data files line-by-line
In-Reply-To: <Law11-F26qXItMcx4vv00017679@hotmail.com>

On Wed, 30 Apr 2003 12:45:33 +0000, RAF wrote:

>Maybe I'm missing something.  When I do readLines( "file", n = 1) and
>repeat, it always reads the first line of "file".  I've to be able to
>advance to the next line, no?
>
>I'll take a look at the command file(), as someone else suggested.

Yes, that's your solution.  

con <- file("foo") 

will open the file called foo and attach it to a connection called
con.  You pass con to readLines, and since the file stays open between
calls, you'll get successive lines.  Remember close(con) when you're
done.

Duncan Murdoch