comparison master/src/wecu/sac_reducer.py @ 58:a3edba8dab11

move to right place in tree
author Henry S. Thompson <ht@markup.co.uk>
date Thu, 28 May 2020 09:56:42 +0000
parents master/wecu/sac_reducer.py@ac1a20e627a9
children 5fdca5baa4e9
comparison
equal deleted inserted replaced
57:ac1a20e627a9 58:a3edba8dab11
1 #!/usr/bin/python
2
3 import sys
4 from collections import defaultdict
5
6 if sys.argv[0] == 'by-file':
7 # Show results by file
8 for line in sys.stdin:
9 print(line.strip())
10 else:
11 # Aggregate results
12 counters = defaultdict(int)
13
14 for line in sys.stdin:
15 try:
16 line = line.strip().split('\t')
17 k = line[0]
18 v = line[1]
19 except:
20 continue
21
22 counters[k] += int(v)
23
24 for k in counters:
25 print("{}\t{}".format(k, counters[k]))