comparison master/wecu/sac_reducer.py @ 57:ac1a20e627a9

from lukasz git repo 2020-05-26 (see ~/src/wecu), then editted, sac not quite working yet
author Henry S. Thompson <ht@markup.co.uk>
date Wed, 27 May 2020 20:54:34 +0000
parents
children
comparison
equal deleted inserted replaced
56:8ce6a81e2bb4 57:ac1a20e627a9
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]))