Mercurial > hg > cc > azure
view master/src/wecu/sac_reducer.py @ 60:5fdca5baa4e9
refactor a bit, add support for sac with bespoke mapper
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Thu, 28 May 2020 12:55:03 +0000 |
parents | a3edba8dab11 |
children | cfaf5223b071 |
line wrap: on
line source
#!/usr/bin/python import sys from collections import defaultdict if sys.argv[1] == 'by-file': # Show results by file for line in sys.stdin: print(line.strip()) else: # Aggregate results counters = defaultdict(int) for line in sys.stdin: try: line = line.strip().split('\t') k = line[0] v = line[1] except: continue counters[k] += int(v) for k in counters: print("{}\t{}".format(k, counters[k]))