[R] Process File Line By Line Without Slurping into Object

Gundala Viswanath gundalav at gmail.com
Mon Jan 5 06:55:27 CET 2009


Dear all,

In general practice one would slurp the whole file
using this method before processing the data:

dat <- read.table(filename)

or variations of it.

Is there a way we can access the file line by line
without slurping/storing them into object?

I am thinking something like this in Perl:

__BEGIN__
open INFILE, '<' , 'filename.txt' or die $!;
while (<INFILE>) {
    my $line = $_;
    # then process line by line
}
__END__

the reason I want to do that is because the data
I am processing are large (~ 5GB), my PC may not
be able to handle that.

- Gundala Viswanath
Jakarta - Indonesia




More information about the R-help mailing list