Mercurial > hg > cc > azure
view master/src/wecu/sac_reducer.py @ 61:cfaf5223b071
trying to get my own mapper working
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Sun, 31 May 2020 12:06:44 +0000 |
parents | 5fdca5baa4e9 |
children | 892e1c0240e1 |
line wrap: on
line source
#!/usr/bin/python3 import sys from collections import defaultdict print('reducing',sys.argv,file=sys.stderr) 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: print('bogus',line,file=sys.stderr) continue counters[k] += int(v) print('nc',len(counters),file=sys.stderr) for k,v in counters.items(): print("{}\t{}".format(k, v))