@@ -0,0 +1,1762 @@
+import nfldb%0A%0Adb = nfldb.connect()%0A%0Ateams = %5B%5D%0Aunknown = 'UNK'%0Awith nfldb.Tx(db) as cursor:%0A    cursor.execute('''%0A        SELECT %25s FROM team WHERE city != %25%25s%0A        ''' %25 '*', (unknown,))%0A    for row in cursor.fetchall():%0A        teams.append(row)%0A%0Aweekly_data = %7B%7D%0Aweek = 17%0Afor i in range(17):%0A    weeks_data = %7B%7D%0A    for t in teams:%0A        q = nfldb.Query(db)%0A        q.game(season_year=2009, season_type='Regular', winner=t%5B'team_id'%5D, week__le=(i+1))%0A        wins = len(q.as_games())%0A        q2 = nfldb.Query(db)%0A        q2.game(season_year=2009, season_type='Regular', loser=t%5B'team_id'%5D, week__le=(i+1))%0A        loses = len(q2.as_games())%0A        WP = (wins/float((wins+loses))) * 100%0A        # print 'Winning Percentage for %25s: %25s%25%25 (Wins:%25s, Loses:%25s)' %25 (t%5B'team_id'%5D,WP, wins, loses)%0A        weeks_data%5Bt%5B'team_id'%5D%5D = %7B'winning_per': WP%7D%0A    for k, v in weeks_data.iteritems():%0A        query = nfldb.Query(db)%0A        query.game(season_year=2009, season_type='Regular', week=(i+1), home_team=k)%0A        games = query.as_games()%0A        if len(games) == 1:%0A            weeks_data%5Bk%5D%5B'opponents_record'%5D = weeks_data%5Bgames%5B0%5D.away_team%5D%5B'winning_per'%5D%0A        else:%0A            query = nfldb.Query(db)%0A            query.game(season_year=2009, season_type='Regular', week=(i+1), away_team=k)%0A            games = query.as_games()%0A            if len(games) == 1:%0A                weeks_data%5Bk%5D%5B'opponents_record'%5D = weeks_data%5Bgames%5B0%5D.home_team%5D%5B'winning_per'%5D%0A    weekly_data%5Bstr(i)%5D = weeks_data%0A%0Afor k, v in weekly_data.iteritems():%0A    print '%5CnWEEK %25s' %25 k%0A    print '-------------------'%0A    for team, stats in v.iteritems():%0A        print 'TEAM: %25s' %25 team%0A        for stat, val in stats.iteritems():%0A            print '%25s: %25s%25%25' %25(stat, val)%0A

add first iteration of nfl predict