Re: huge file : parsing problem
- From: shawnhcorey@xxxxxxxx (Mr. Shawn H. Corey)
- Date: Wed, 29 Mar 2006 11:17:21 -0500
On Wed, 2006-29-03 at 15:53 +0000, Saurabh Singhvi wrote:
HI there,
I have a huge file (~7GB) of text data. I need to parse it to extract
something : basically minima and maxima, and then i need to quantify
the data into an output file based on ranges.
Now the problem is that the traditional method of opening and foreach
which is as follows:
open(FILE,"data.txt");
$min = 100;
$max = 0;
foreach $data (<FILE>) {
while( $data = <FILE> ){
if ($min > $data ) {--
$min = $data ;
}
elsif ($max < $data) {
$max = $data ;
}
}
print $max, $min;
close FILE;
fails to work, as perl is trying to load the complete file into memory!
Now i also tried changing it to STDIN instead, by catting the data from
the text file.
./script.pl < data.txt
but this too gave the same error
Out of memory!
So kindly help me on how to do this thing.
thanks
Saurabh
__END__
Just my 0.00000002 million dollars worth,
--- Shawn
"For the things we have to learn before we can do them,
we learn by doing them."
Aristotle
* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/
.
- References:
- huge file : parsing problem
- From: Saurabh Singhvi
- huge file : parsing problem
- Prev by Date: huge file : parsing problem
- Next by Date: RE: Sub coding question...
- Previous by thread: huge file : parsing problem
- Next by thread: Re: huge file : parsing problem
- Index(es):
Relevant Pages
|