def rank(x): return utilities.rankSmart([float(y) for y in x])
def rankprob(x): length = float(len(x)) return [float(y) / length for y in utilities.rankSmart([float(y) for y in x])]
import os, sys, glob import utilities inFilePath = sys.argv[1] hasHeader = sys.argv[2] == "True" columnIndex = int(sys.argv[3]) decreasing = sys.argv[4] == "True" outFilePath = sys.argv[5] data = utilities.readMatrixFromFile(inFilePath) header = None if hasHeader: header = data.pop(0) values = [float(x[columnIndex]) for x in data] ranks = utilities.rankSmart(values, decreasing=decreasing, ties="average") outData = [] for i in range(len(data)): outData.append(data[i] + [str(ranks[i])]) if header != None: outData.insert(0, header) utilities.writeMatrixToFile(outData, outFilePath)