PHP - Average Movie Ratings
► Problem Description: The Netflix Prize was a competition which began in 2006. It provided anonymized user ratings for over 17,000 titles. We'll use that data set for this problem and the other example php programs.
You are to read the file 'movie_titles.txt' which has 17,700 entries, each with the following format:
id,year,title
The id will be 1 -> 17700 (there are no gaps) and these numbers correspond to the files in the 'training_set' folder. For example, 'The Shawshank Redemption' from 1994 has an id of: 14550. This means, this file:
mv_0014550.txt
will contain the ratings for that movie in that training_set folder. Note that there are always 7 digits after the 'mv_' part, each movie id is zero padded to the right length so if we had:
1666,1995,The Brady Bunch Movie
Then the corresponding filename would be:
mv_0001666.txt
The goal then, is to produce a file 'all.txt' with this format:
average-rating,number-of-ratings,year,title
The average rating should be limited to 2 decimal places, here are the first few lines of 'all.txt' as an example:
3.75,547,2003,Dinosaur Planet 3.56,145,2004,Isle of Man TT 2004 Review 3.64,2012,1997,Character 2.74,142,1994,Paula Abdul's Get Up & Dance 3.92,1140,2004,The Rise and Fall of ECW
► Source Code