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 reply to Re: Calculating the average on a timeslice of data
by zek152
in thread Calculating the average on a timeslice of data
by perlbrother
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |