Mercurial > hg > lib > markup
changeset 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 | 2b399c612a3e |
children | 56508a6033a9 |
files | python/sumUC.py |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
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)