#!/usr/bin/python import sys from commons import print_result if __name__ == "__main__": max_key = None max_value = 0 curr_key = None acc = 0 for line in sys.stdin: data = line.strip().split("\t") new_key = data[0] new_value = float(data[1]) if curr_key != new_key: if acc > max_value: max_key = curr_key max_value = acc curr_key = new_key acc = new_value else: acc += new_value print_result(max_key, max_value)
#!/usr/bin/python import sys from commons import print_result if __name__ == "__main__": curr_key = None acc = 0. for line in sys.stdin: data = line.strip().split("\t") new_key = data[0] new_value = float(data[1]) if curr_key != new_key: print_result(curr_key, acc) curr_key = new_key acc = new_value else: acc += new_value print_result(curr_key, acc)
def print_count_and_words(key, words): print_result(key, "count: {0}, {1}".format(len(words), str(words)))
#!/usr/bin/python import sys from commons import print_result if __name__ == "__main__": curr_max_key = None max_value = 0. for line in sys.stdin: data = line.strip().split("\t") new_key = data[0] new_value = float(data[1]) if curr_max_key != new_key: print_result(curr_max_key, max_value) curr_max_key = new_key max_value = new_value else: if new_value > max_value: max_value = new_value print_result(curr_max_key, max_value)
def print_count_and_amount(key, count, amount): mean = 0 if count == 0 else amount / count print_result( key, "count: {0}, amount: {1}, mean: {2}".format(count, amount, mean))