-
Notifications
You must be signed in to change notification settings - Fork 3
/
result.py
60 lines (45 loc) · 1.43 KB
/
result.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from math import isnan
from pandas import read_csv
results = read_csv("input/results.csv")
res = {}
l = len(results.values)
ponderation = [4, 2, 1]
from functools import cmp_to_key
def cmp_scores(a, b):
if a[1]["points"] > b[1]["points"]:
return 1
elif a[1]["points"] < b[1]["points"]:
return -1
elif a[1]["positions"][1] > b[1]["positions"][1]:
return 1
elif a[1]["positions"][1] < b[1]["positions"][1]:
return -1
return -1
def cmp_print(a, b):
print(a[1], b[1])
return 0
cols = len(results.columns)
for c in range(7, cols):
end = results.columns[c].find('?')
poste = results.columns[c][28:end]
cl = results.columns[c].find('Classement')
classement = int(results.columns[c][cl+11])
points = ponderation[classement-1]
for reponse in results.values:
value = reponse[c]
if isinstance (value, float):
continue
if(not poste in res):
res[poste] = {}
if not value in res[poste]:
res[poste][value] = {
"points": 0,
"positions": {1: 0, 2: 0, 3: 0}
}
res[poste][value]["points"] += points
res[poste][value]["positions"][classement] += 1
for poste in res:
print(poste)
scoreTuples = sorted(res[poste].items(), key=cmp_to_key(cmp_scores), reverse=True)
for score in scoreTuples:
print(score)