-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_filtering.py
47 lines (38 loc) · 1014 Bytes
/
data_filtering.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
fi = open("boxing.csv", "r+")
fo = open("data.csv", "a")
temp = fi.read().splitlines()
stances_names = []
stances_nums = []
for x in range(1, len(temp)):
ln = temp[x].split(',')
stanceA = ln[6]
stanceB = ln[7]
res = ln[-1]
is_orthodox_A = 0
is_orthodox_B = 0
is_southpaw_A = 0
is_southpaw_B = 0
result = 0
if '' not in ln:
# Stances
if stanceA == "orthodox":
is_orthodox_A = 1
else:
is_southpaw_A = 1
if stanceB == "orthodox":
is_orthodox_B = 1
else:
is_southpaw_B = 1
# Result
if res == 'win_A':
result = 1
elif res == 'win_B':
result = 2
else:
result = 0
# Append
final_ln = ",".join(ln[0:6] + [str(is_orthodox_A), str(is_orthodox_B), str(is_southpaw_A), str(is_southpaw_B)] + ln[8:18] + [str(result)])
print(final_ln)
fo.write("\n{}".format(final_ln))
fi.close()
fo.close()