Created
July 5, 2017 00:03
-
-
Save mmas/b7286d20d5f1475f13d2c0e18b90aa81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
last_k = None | |
last_v = 0 | |
for line in sys.stdin: | |
k, v = line.strip().split('\t') | |
v = int(v) | |
if last_k == k: | |
last_v += v | |
else: | |
if last_k: | |
print '%s\t%s' % (last_k, last_v) | |
last_k = k | |
last_v = v | |
if last_k == k: | |
print '%s\t%s' % (last_k, last_v) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment