|
|
| Just another Perl shrine | |
| PerlMonks |
Re: Calculating the average on a timeslice of databy zek152 (Pilgrim) |
| on Jul 06, 2011 at 15:40 UTC ( [id://913007]=note: print w/replies, xml ) | Need Help?? |
|
Specify how much "a lot of data" is. Are we talking thousands of lines or millions or billions? Personally I would split on white space, then do something like: if($line[1]=="0109") { $sum += $line[2]; $n+=1; }I ran this on a file with 1000000 lines and it took about 3 seconds to run. There were 83333 matches for that particular date. The complexity is O(n) so it should scale linearly with increased input sizes.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||