view 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 source

#!/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)