Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- last_key = None
- running_total = []
- for input_line in sys.stdin:
- input_line = input_line.strip()
- this_key, value = input_line.split("\t", 1)
- if last_key == this_key:
- running_total.append(value)
- else:
- if last_key:
- print( "%s\t%d" % (last_key, running_total) )
- running_total = value
- last_key = this_key
- if last_key == this_key:
- print( "%s\t%d" % (last_key, running_total) )
Add Comment
Please, Sign In to add comment