annotate python/sumUC.py @ 13:1cd5c7952aaa default tip

fix failure to read first line of Air/Lava, keep me from swimming in Lava, again!
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Sun, 30 Jan 2022 14:49:33 -0500
parents 870e13483642
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
870e13483642 sum outputs from multiple uniq -c, maybe?
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
1 #!/usr/bin/python
870e13483642 sum outputs from multiple uniq -c, maybe?
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
2 import sys
870e13483642 sum outputs from multiple uniq -c, maybe?
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
3 ss={}
870e13483642 sum outputs from multiple uniq -c, maybe?
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
4 n=0
870e13483642 sum outputs from multiple uniq -c, maybe?
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
5 for l in sys.stdin:
870e13483642 sum outputs from multiple uniq -c, maybe?
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
6 (count,key)=l.strip().split()
870e13483642 sum outputs from multiple uniq -c, maybe?
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
7 ss[key]=ss.get(key,0)+int(count)
870e13483642 sum outputs from multiple uniq -c, maybe?
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
8 n+=1
870e13483642 sum outputs from multiple uniq -c, maybe?
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
9 tt=0
870e13483642 sum outputs from multiple uniq -c, maybe?
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
10 for (key,total) in ss.items():
870e13483642 sum outputs from multiple uniq -c, maybe?
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
11 tt+=total
870e13483642 sum outputs from multiple uniq -c, maybe?
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
12 print "%s\t%s"%(key,total)
870e13483642 sum outputs from multiple uniq -c, maybe?
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
13 print >>sys.stderr,"%s vs. %s"%(n,tt)