示例#1
0
def get_lineups():
    lineups = []
    while len(lineups) < 100:

        rb1 = random.choice(test.rb1s())
        print rb1
        rb2 = random.choice(test.rb1s())
        print rb2
        wr1 = random.choice(test.wr1s())
        print wr1
        wr2 = random.choice(test.wr1s())
        print wr2
        wr3 = random.choice(test.wr1s())
        print wr3
        te = random.choice(test.tes())
        print te
        for x in test.qbs():
            results = connect("SELECT qb,rb1,rb2,wr1,wr2,wr3,te,flex,dst,oppscore FROM teams WHERE qb=? and wr1=? and wr2=? and wr3=? and rb1=? and rb2=? and te=? ORDER BY oppscore DESC LIMIT 1", (x,wr1,wr2,wr3,rb1,rb2,te))
            if results:
                for row in results:
                    lineups.append(row)
        print len(lineups)

            


    return sorted(lineups, key=lambda k: k[9], reverse=True)
示例#2
0
def get_bstlineqb(lineups):
    qbs = test.qbs()
    rbs = test.get_rankedlist(test.rb1s())
    print rbs
    wrs = test.get_rankedlist(test.wr1s())
    print wrs
    new_lineups = []
    for x in qbs:
        h = 0
        for lineup in lineups:
           if lineup['qb']['Name'] == x:
               if lineup['rb1']['Name'] == rbs[h]:
                   if lineup['wr1']['Name'] == wrs[h]:
                       if teamcheck(lineup):
                           lst.append(lineup)
               if lst:
                   best.append(sorted(lst, key = lambda k: k['Oppscore'], reverse=True)[0])
                h = h + 1
        for z in best:
            new_lineups.append(z)
    return new_lineups
示例#3
0
import sqlite3 as lite
import json,csv,test,operator,random

allplayers = test.qbs() + test.rb1s() + test.rb2s() + test.wr1s() + test.wr2s() + test.wr3s() + test.tes()

def connect(command,options):
    con = lite.connect('dksalary.db')

    with con:
        #con.row_factory = lite.row
        cur = con.cursor()

        cur.execute(command,options)
        rows = cur.fetchall()
    return rows

def WriteListToCSV(csv_file,csv_columns,data_list):
    try:
        with open(csv_file, 'w') as csvfile:
            writer = csv.writer(csvfile, dialect='excel', quoting=csv.QUOTE_NONNUMERIC)
            writer.writerow(csv_columns)
            for data in data_list:
                writer.writerow(data)
    except IOError as (errno, strerror):
            print("I/O error({0}): {1}".format(errno, strerror))
    return 

def get_lineups():
    lineups = []
    while len(lineups) < 100: