Mercurial > hg > cc > azure
comparison 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 |
comparison
equal
deleted
inserted
replaced
60:5fdca5baa4e9 | 61:cfaf5223b071 |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python3 |
2 | 2 |
3 import sys | 3 import sys |
4 from collections import defaultdict | 4 from collections import defaultdict |
5 | |
6 print('reducing',sys.argv,file=sys.stderr) | |
5 | 7 |
6 if sys.argv[1] == 'by-file': | 8 if sys.argv[1] == 'by-file': |
7 # Show results by file | 9 # Show results by file |
8 for line in sys.stdin: | 10 for line in sys.stdin: |
9 print(line.strip()) | 11 print(line.strip()) |
15 try: | 17 try: |
16 line = line.strip().split('\t') | 18 line = line.strip().split('\t') |
17 k = line[0] | 19 k = line[0] |
18 v = line[1] | 20 v = line[1] |
19 except: | 21 except: |
22 print('bogus',line,file=sys.stderr) | |
20 continue | 23 continue |
21 | 24 |
22 counters[k] += int(v) | 25 counters[k] += int(v) |
23 | 26 |
24 for k in counters: | 27 print('nc',len(counters),file=sys.stderr) |
25 print("{}\t{}".format(k, counters[k])) | 28 for k,v in counters.items(): |
29 print("{}\t{}".format(k, v)) |