diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/master/wecu/sac_reducer.py	Wed May 27 20:54:34 2020 +0000
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+
+import sys
+from collections import defaultdict
+
+if sys.argv[0] == '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]))