Example #1
0
def final_answer2():
    print(main.teamname1(), new_answer[0], main.teamname2(), new_answer[1])
    for item in new_answer:
        if item == 0:
            new_answer[item] = 0.0000000001
    #print(abs(float(new_answer[1]) / float(new_answer[0])))
    if abs(float(new_answer[0]) / float(
            new_answer[1])) or float(new_answer[1]) / float(new_answer[0]) > 5:

        print("Game should have at least ten point spread!")
    if new_answer[0] > new_answer[1]:
        print("Team : ", main.teamname1(), " should win!")
    else:
        print("Team : ", main.teamname2(), " should win!")
    del new_answer[:]
Example #2
0
def prob_of_win():
    if main.teamname() == main.teamname1():

        with open(main.teamname1() + 'data.csv', 'r') as csvfile:
            next(csvfile)
            read = csv.reader(csvfile, delimiter=' ', quotechar=',')
            wins = 0
            for row in read:

                for word in row:
                    #print(word)
                    word = word.split(",")
                    #print(word)
                    if '1' in word[-1]:
                        wins += 1
            chances = ((wins / numOfGames) + 0.5) / 2
            print(chances)
            prob_win.append(chances)
            return (chances)
    else:
        with open(main.teamname2() + 'data.csv', 'r') as csvfile:
            next(csvfile)
            read = csv.reader(csvfile, delimiter=' ', quotechar=',')
            wins = 0
            for row in read:

                for word in row:
                    #print(word)
                    word = word.split(",")
                    #print(word)
                    if '1' in word[-1]:
                        wins += 1

            print(((wins / numOfGames) + 0.5) / 2)
            return (((wins / numOfGames) + 0.5) / 2)
Example #3
0
def append_csv():
    team1 = main.teamname1()
    prob_of_win(team=team1)
    with open(team1 + "data.csv", "a") as f:


        for i in range(numOfAttrs):
            givenwin.append(p_x_y(i, team1)[0])
        givenwin.append(prob_of_win(team1))
        #givenloss.append(p_x_y(i)[1])
        wr = csv.writer(f)
        wr.writerow(givenwin)

    team2 = main.teamname2()
    prob_of_win(team=team2)

    del givenwin[:]
    with open(team2 + "data.csv", "a") as f:


        for i in range(numOfAttrs):
            givenwin.append(p_x_y(i, team2)[0])
        givenwin.append(prob_of_win(team2))
        wr = csv.writer(f)
        wr.writerow(givenwin)
Example #4
0
def bulk():
    teamname()
    team = main.teamname1()
    #createTrainingCSV()
    #Writes out first line with team name
    #createCSV(team)

    list = main.list(team)
    for item in list:

        html = requests.get(item).text
        soup = BeautifulSoup(html, 'html5lib')
        # GRAB ALL STAT INFO
        for td_tag in soup.find_all('td'):
            each_stat = td_tag.text
            stats.append(each_stat)
            stat = [x.replace('\t', '').replace('\n', '') for x in stats]

        teamstats(team)
        appendCSV(team)
        del stats[:]
        del team1list[:]
        del team2list[:]
        #del stat[:]

    team2 = main.teamname2()


    list = main.list(team2)
    for item in list:

        html = requests.get(item).text
        soup = BeautifulSoup(html, 'html5lib')
        # GRAB ALL STAT INFO
        for td_tag in soup.find_all('td'):
            each_stat = td_tag.text
            stats.append(each_stat)
            stat = [x.replace('\t', '').replace('\n', '') for x in stats]
        #print(stat)
        teamstats(team2)
        appendCSV(team2)
        del stats[:]
        del team1list[:]
        del team2list[:]

#bulk()
Example #5
0
def openCSV2(team):
    with open(team + 'data.csv', 'r') as csvfile:
        next(csvfile)

        lastLine = csvfile.readlines()[-1]
        a = lastLine.split(",")

        for item in a:
            last_line.append(item)
        revised_line = [
            x.replace('\t', '').replace('\n', '') for x in last_line
        ]

        for item in revised_line:
            #print(item)
            if team == main.teamname1():
                team1ListW_FS.append(item)
            if team == main.teamname2():
                team2ListW_FS.append(item)
        del last_line[:]
Example #6
0
def openCSV(team):
    with open(team + 'data.csv', 'r') as csvfile:
        next(csvfile)
        #read = csv.reader(csvfile, delimiter=' ', quotechar=',')
        lastLine = csvfile.readlines()[-1]
        a = lastLine.split(",")

        for item in a:
            last_line.append(item)
        revised_line = [
            x.replace('\t', '').replace('\n', '') for x in last_line
        ]
        #print(revised_line)
        for item in revised_line:
            #print(item)
            if team == main.teamname1():
                team1List.append(item)
            if team == main.teamname2():
                team2List.append(item)
        del last_line[:]
Example #7
0
def runAgainWithFS():
    openCSV2(main.teamname1())
    openCSV2(main.teamname2())
Example #8
0
def teamname():
    teamnames.append(main.teamname1())
    teamnames.append(main.teamname2())
Example #9
0
def compareAttrs():
    openCSV(main.teamname1())
    openCSV(main.teamname2())
Example #10
0
def final_answer():
    if answer[0] > answer[1]:
        print("Team : ", main.teamname1(), " should win!")
    else:
        print("Team : ", main.teamname2(), " should win!")