#!/usr/bin/python import sys sk_file = open(sys.argv[1]) labels = sk_file.readline().strip().split(',') end = labels.index('h-sc') print(','.join(labels[0:end] + ["height"])) for line in sk_file: line = line.strip().split(',') out = line[0:end] height = 0.0 for limb in map(lambda x: float(line[labels.index(x)]), ['h-sc','sc-s','s-hc','hi-kn','kn-an']): if limb > 0: height += limb else: height = -1 break out += [str(height)] print(','.join(out))