adding simple mathematical operation to python script -
i have program operates on csv file create output looks this:
724, 2 724, 1 725, 3 725, 3 726, 1 726, 0
i modify script simple math operations such render output:
724, 1.5 725, 3 726, 0.5
the script i'm using here:
lines=open("1.txt",'r').read().splitlines() l in lines: data = l.split('"overall evaluation:') if len(data) == 2: print(data[0] + ", " + data[1])
how add simple averaging , slicing operation pipeline?
i guess need create temporary variable, should outside loop iterates on lines?
maybe this:
lines=open("easychairdata.csv",'r').read().splitlines() l in lines: data = l.split('"overall evaluation:') submission_number_repo = data[0] if len(data) == 2: print(data[0] + ", " + data[1]) if submission_number_repo != data[0] submission_number_repo = data[0]
edit
the function simple average
you can use dictionary map key total , count , print it:
map = {} lines=open("1.txt",'r').read().splitlines() l in lines: data = l.split('"overall evaluation:') if len(data) == 2: if data[0] not in map.keys(): map[data[0]] = (0,0) map[data[0]] = (map[data[0]][0]+int(data[1]) , map[data[0]][1]+1) x, y in map.items(): print(str(x) + ", " + str(y[0]/y[1]))
Comments
Post a Comment