Compute Weighted Average

I haven't been able to test this properly and I'll keep working on it tomorrow, but I think this is what you're looking for as far as a script that reads from a local text file?

It assumes that the examples are line-separated and the rating and count are space-separated as in:
20 80 (rating, count)
30 90