Created
July 5, 2017 00:02
-
-
Save mmas/572461f76fc3723314a2454937f95b2a 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 | |
max_v = 0 | |
for line in sys.stdin: | |
k, v = line.strip().split('\t') | |
v = int(v) | |
if last_k == k: | |
max_v = max(max_v, v) | |
else: | |
if last_k: | |
print '%s\t%s' % (last_k, max_v) | |
last_k = k | |
max_v = v | |
if last_k == k: | |
print '%s\t%s' % (last_k, max_v) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment