Re: Calcualting Avg.

2007-12-07 Thread Rob Dixon
Mike Tran wrote: > > The code below is what I got so far, but I'm still getting the "|0.0" > for the first row returned. I don't know which part of the code is > generating this, could someone help explain this to me? Thanks for all > your help. > > new_ratings.txt: > > base_no|AvgRating > |0.0 >

RE: Calcualting Avg.

2007-12-07 Thread Mike Tran
msum{$num} += $rate; ++$numcnt{$num}; } for (sort keys %numsum){ my $numavg = sprintf "%.1f",$numsum{$_} / $numcnt{$_}; print OUT "$_\|$numavg\n"; } close($fh); close(OUT); ____ From: michael wang [mailto:[EMAIL PROTECTE

Re: Calcualting Avg.

2007-12-07 Thread Gunnar Hjalmarsson
Mike Tran wrote: I have a file which has two columns one called Basenumber the other Rating (Rating.txt), how do I loop through and get an average for the Rating column for each distinct baseNumber? Use a hash. I want to write the new result out into a new file called AvgRatings.txt. What h

Re: Calcualting Avg.

2007-12-07 Thread michael wang
Hi On 12/7/07, Mike Tran <[EMAIL PROTECTED]> wrote: > > Hi All, > > > > I'm not very familiar with Perl yet, so could someone help me with this > please? I have a file which has two columns one called Basenumber the > other Rating (Rating.txt), how do I loop through and get an average for > the Ra

Calcualting Avg.

2007-12-07 Thread Mike Tran
Hi All, I'm not very familiar with Perl yet, so could someone help me with this please? I have a file which has two columns one called Basenumber the other Rating (Rating.txt), how do I loop through and get an average for the Rating column for each distinct baseNumber? I want to write the new r