My mapper is:
import sys
for line in sys.stdin:
# split line into the four fields
fields = line.strip().split("\t")
value = fields[2] #rating
key = fields[3] #timestamp in unix seconds
print(key, value, sep="\t")
My reducer is:
import sys
(last_key , count) = (None, 0)
for line in sys.stdin:
(key, value) = line.strip().split("\t")
if (last_key and last_key !=key):
print(last_key, count, sep="\t")
count=0
last_key = key
count += int(value)
print(last_key, count, sep="\t")
How to I get the number of ratings? The mapper works fine. And when should I convert the timestamp (last_key in this case)
Output should be (year-month \t number of rating records)