Skip to content
Back to formatted view

Raw Message

Message-ID: <497053A6.4020605@idi.ntnu.no>
Date: 2009-01-16T09:30:14Z
From: Wacek Kusnierczyk
Subject: Value Lookup from File without Slurping
In-Reply-To: <73f827b50901160102x572d0018v39f221d854d4c0e5@mail.gmail.com>

you might try to iteratively read a limited number of line of lines in a
batch using readLines:

# filename, the name of your file
# n, the maximal count of lines to read in a batch
connection = file(filename, open="rt")
while (length(lines <- readLines(con=connection, n=n))) {
   # do your stuff here
}
close(connection)

?file
?readLines

vQ


Gundala Viswanath wrote:
> Dear all,
>
> I have a repository file (let's call it repo.txt)
>  that contain two columns like this:
>
> # tag  value
> AAA    0.2
> AAT    0.3
> AAC   0.02
> AAG   0.02
> ATA    0.3
> ATT   0.7
>
> Given another query vector
>
>   
>> qr <- c("AAC", "ATT")
>>     
>
> I would like to find the corresponding value for each query above,
> yielding:
>
> 0.02
> 0.7
>
> However, I want to avoid slurping whole repo.txt into an object (e.g. hash).
> Is there any ways to do that?
>
> The reason I want to do that because repo.txt is very2 large size
> (milions of lines,
> with tag length > 30 bp),  and my PC memory is too small to keep it.
>
>