Mercurial > hg > lib > markup
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/sumUC.py Tue May 25 14:00:47 2021 -0400 @@ -0,0 +1,13 @@ +#!/usr/bin/python +import sys +ss={} +n=0 +for l in sys.stdin: + (count,key)=l.strip().split() + ss[key]=ss.get(key,0)+int(count) + n+=1 +tt=0 +for (key,total) in ss.items(): + tt+=total + print "%s\t%s"%(key,total) +print >>sys.stderr,"%s vs. %s"%(n,tt)