Mercurial > hg > lib > markup
comparison python/sumUC.py @ 3:870e13483642
sum outputs from multiple uniq -c, maybe?
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Tue, 25 May 2021 14:00:47 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:2b399c612a3e | 3:870e13483642 |
---|---|
1 #!/usr/bin/python | |
2 import sys | |
3 ss={} | |
4 n=0 | |
5 for l in sys.stdin: | |
6 (count,key)=l.strip().split() | |
7 ss[key]=ss.get(key,0)+int(count) | |
8 n+=1 | |
9 tt=0 | |
10 for (key,total) in ss.items(): | |
11 tt+=total | |
12 print "%s\t%s"%(key,total) | |
13 print >>sys.stderr,"%s vs. %s"%(n,tt) |