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
>
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
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
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
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