Last active
February 4, 2016 17:15
-
-
Save korjavin/8f51d62c4021d4d3b77d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!env python | |
import sys | |
(lastKey,minDist,minVals)=(None,0,'') | |
for line in sys.stdin: | |
arr = line.strip().split("\t") | |
v=arr[0] | |
d=arr[1] | |
vals=arr[2].replace('{','').replace('}','') | |
if lastKey and lastKey != v: | |
x = "%.3f" % (0.2*0.1+0.9*minDist) | |
print (lastKey + '\t' + x + '\t{' + minVals + '}') | |
(lastKey,minDist,minVals)=(v,0,'') | |
else: | |
lastKey =v | |
if vals!='': | |
minVals=vals | |
else: | |
minDist+=float(d) | |
if lastKey : | |
x = "%.3f" % (0.2*0.1+0.9*minDist) | |
print (lastKey + '\t' + x + '\t{' + minVals + '}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment