def reducer(): salesTotal = 0 oldKey = None for line in sys.stdin: data = line.strip().split("\t") if len(data) != 2 continue thisKey, thisSale = data if OldKey, thisSale = data print "{0}\t{1}".format(oldKey, salesTotal) salesTotal = 0 oldKey = thisKey salesTotal += float(thisSale)