-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcommonlabels.py
More file actions
68 lines (59 loc) · 1.85 KB
/
commonlabels.py
File metadata and controls
68 lines (59 loc) · 1.85 KB
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
61
62
63
64
65
66
67
68
#Owen Chapman
#odds analysis
#this script was just to run and check some common variables across our
#data set. i've done it, so we shouldnt need to run this code.
import csv
def findall(rcsv, labellist):
reader=csv.DictReader(rcsv)
for row in reader:
for label in row.keys():
if label not in labellist:
labellist.append(label)
break
def findcommon (rcsv, labellist):
reader=csv.DictReader(rcsv)
for row in reader:
for label in labellist:
if label not in row.keys():
labellist.remove(label)
break
def check(needevery,stillneedevery):
r=[]
for i in range(len(needevery)):
item=needevery[i]
if item in stillneedevery:
r.append(item)
return r
def getoddslist(r):
keys=[]
for row in r:
row=row.strip()
row=row.split()
keys.append(row[0])
return keys
keys=['FTHG','FTAG','HS','AS','HST','AST','HC','AC','HF','AF',"AO","HO",'HY','AY','HR','AR']
oddskeys=['IWH', 'IWD', 'IWA', 'LBH', 'LBD', 'LBA', 'WHH', 'WHD', 'WHA']
#main method
YEAR_START = 2000
YEAR_END = 2013
def run():
#empty alldata.csv
alllabels=[]
for year in range(YEAR_START, YEAR_END+1):
fname="raw/"+str(year)+" raw.csv"
with open(fname,'r') as f:
findall(f, alllabels)
f.close()
for year in range(YEAR_START, YEAR_END+1):
fname="raw/"+str(year)+" raw.csv"
with open(fname,'r') as f:
findcommon(f, alllabels)
f.close()
#checked that all the keys used are in all of the sets
#print check(keys,alllabels)
#checked which odds are in all of our files, stored in oddskeys
## r=open('betting odds key.txt')
## oddslist=getoddslist(r)
## print 'oddslist',oddslist
## print 'alllist',alllabels
## print check(oddslist,alllabels)