예제 #1
0
def parse_data():
    """ Parse and store all the data
    """
    print("Getting data")
    data = get_data()
    season = '2018-19'
    base_filename = 'data/' + season + '/'
    print("Parsing summary data")
    parse_players(data["elements"], base_filename)
    gw_num = data["current-event"]
    print("Cleaning summary data")
    clean_players(base_filename + 'players_raw.csv', base_filename)
    print("Extracting player ids")
    id_players(base_filename + 'players_raw.csv', base_filename)
    player_ids = get_player_ids(base_filename)
    # TODO: parse other stats that may be useful
    num_players = len(data["elements"])
    player_base_filename = base_filename + 'players/'
    gw_base_filename = base_filename + 'gws/'
    print("Extracting player specific data")
    for i in range(num_players):
        player_data = get_individual_player_data(i + 1)
        parse_player_history(player_data["history_past"], player_base_filename,
                             player_ids[i + 1], i + 1)
        parse_player_gw_history(player_data["history"], player_base_filename,
                                player_ids[i + 1], i + 1)
    print("Collecting gw scores")
    collect_gw(gw_num, player_base_filename, gw_base_filename)
    print("Merging gw scores")
    merge_gw(gw_num, gw_base_filename)
def parse_data():
    """ Parse and store all the data
    """
    print("Getting data")
    data = get_data()
    season = '2018-19'
    base_filename = 'data/' + season + '/'
    print("Parsing summary data")
    parse_players(data["elements"], base_filename)
    gw_num = data["current-event"]
    print("Cleaning summary data")
    clean_players(base_filename + 'players_raw.csv', base_filename)
    print("Extracting player ids")
    id_players(base_filename + 'players_raw.csv', base_filename)
    player_ids = get_player_ids(base_filename)
    # TODO: parse other stats that may be useful
    num_players = len(data["elements"])
    player_base_filename = base_filename + 'players/'
    gw_base_filename = base_filename + 'gws/'
    print("Extracting player specific data")
    for i in range(num_players):
        player_data = get_individual_player_data(i+1)
        parse_player_history(player_data["history_past"], player_base_filename, player_ids[i+1], i+1)
        parse_player_gw_history(player_data["history"], player_base_filename, player_ids[i+1], i+1)
    print("Collecting gw scores")
    collect_gw(gw_num, player_base_filename, gw_base_filename) 
    print("Merging gw scores")
    merge_gw(gw_num, gw_base_filename)
예제 #3
0
def parse_data():
    """ Parse and store all the data
    """
    season = '2021-22'
    base_filename = 'data/' + season + '/'
    print("Getting data")
    data = get_data()
    print("Parsing summary data")
    parse_players(data["elements"], base_filename)
    xPoints = []
    for e in data["elements"]:
        xPoint = {}
        xPoint['id'] = e['id']
        xPoint['xP'] = e['ep_this']
        xPoints += [xPoint]
    gw_num = 0
    events = data["events"]
    for event in events:
        if event["is_current"] == True:
            gw_num = event["id"]
    print("Cleaning summary data")
    clean_players(base_filename + 'players_raw.csv', base_filename)
    print("Getting fixtures data")
    fixtures(base_filename)
    print("Getting teams data")
    parse_team_data(data["teams"], base_filename)
    print("Extracting player ids")
    id_players(base_filename + 'players_raw.csv', base_filename)
    player_ids = get_player_ids(base_filename)
    num_players = len(data["elements"])
    player_base_filename = base_filename + 'players/'
    gw_base_filename = base_filename + 'gws/'
    print("Extracting player specific data")
    for i, name in player_ids.items():
        player_data = get_individual_player_data(i)
        parse_player_history(player_data["history_past"], player_base_filename,
                             name, i)
        parse_player_gw_history(player_data["history"], player_base_filename,
                                name, i)
    if gw_num > 0:
        print("Writing expected points")
        with open(os.path.join(gw_base_filename, 'xP' + str(gw_num) + '.csv'),
                  'w+') as outf:
            w = csv.DictWriter(outf, ['id', 'xP'])
            w.writeheader()
            for xp in xPoints:
                w.writerow(xp)
        print("Collecting gw scores")
        collect_gw(gw_num, player_base_filename, gw_base_filename,
                   base_filename)
        print("Merging gw scores")
        merge_gw(gw_num, gw_base_filename)
    understat_filename = base_filename + 'understat'
    parse_epl_data(understat_filename)
예제 #4
0
def parse_data():
    """Parse and store all the data"""
    base_filename = "data/" + SEASON + "/"
    print("Getting data")
    data = get_data()
    print("Parsing summary data")
    parse_players(data["elements"], base_filename)
    xPoints = []
    for e in data["elements"]:
        xPoint = {}
        xPoint["id"] = e["id"]
        xPoint["xP"] = e["ep_this"]
        xPoints += [xPoint]
    gw_num = 0
    events = data["events"]
    for event in events:
        if event["is_current"]:
            gw_num = event["id"]
    print("Cleaning summary data")
    clean_players(base_filename + "players_raw.csv", base_filename)
    print("Getting fixtures data")
    fixtures(base_filename)
    print("Getting teams data")
    parse_team_data(data["teams"], base_filename)
    print("Extracting player ids")
    id_players(base_filename + "players_raw.csv", base_filename)
    player_ids = get_player_ids(base_filename)
    # num_players = len(data["elements"])
    player_base_filename = base_filename + "players/"
    gw_base_filename = base_filename + "gws/"
    print("Extracting player specific data")
    for i, name in player_ids.items():
        player_data = get_individual_player_data(i)
        parse_player_history(player_data["history_past"], player_base_filename,
                             name, i)
        parse_player_gw_history(player_data["history"], player_base_filename,
                                name, i)
    if gw_num > 0:
        print("Writing expected points")
        with open(os.path.join(gw_base_filename, "xP" + str(gw_num) + ".csv"),
                  "w+") as outf:
            w = csv.DictWriter(outf, ["id", "xP"])
            w.writeheader()
            for xp in xPoints:
                w.writerow(xp)
        print("Collecting gw scores")
        collect_gw(gw_num, player_base_filename, gw_base_filename)
        print("Merging gw scores")
        merge_gw(gw_num, gw_base_filename)
    understat_filename = base_filename + "understat"
    parse_epl_data(understat_filename)
예제 #5
0
def parse_data():
    """ Parse and store all the data
    """
    print("Getting data")
    data = get_data()
    season = '2020-21'
    base_filename = 'data/' + season + '/'
    print("Parsing summary data")
    parse_players(data["elements"], base_filename)
    gw_num = 0
    events = data["events"]
    for event in events:
        if event["is_current"] == True:
            gw_num = event["id"]
    print("Cleaning summary data")
    clean_players(base_filename + 'players_raw.csv', base_filename)
    print("Getting fixtures data")
    fixtures(base_filename)
    print("Getting teams data")
    parse_team_data(data["teams"], base_filename)
    print("Extracting player ids")
    id_players(base_filename + 'players_raw.csv', base_filename)
    player_ids = get_player_ids(base_filename)
    num_players = len(data["elements"])
    player_base_filename = base_filename + 'players/'
    gw_base_filename = base_filename + 'gws/'
    print("Extracting player specific data")
    for i, name in player_ids.items():
        player_data = get_individual_player_data(i)
        parse_player_history(player_data["history_past"], player_base_filename,
                             name, i)
        parse_player_gw_history(player_data["history"], player_base_filename,
                                name, i)
    if gw_num > 0:
        print("Collecting gw scores")
        collect_gw(gw_num, player_base_filename, gw_base_filename)
        print("Merging gw scores")
        merge_gw(gw_num, gw_base_filename)
    understat_filename = base_filename + 'understat'
    parse_epl_data(understat_filename)
def parse_data():
    """ Parse and store all the data
    """
    print("Getting data")
    data = get_data()
    season = '2019-20'
    base_filename = 'data/' + season + '/'
    print("Parsing summary data")
    parse_players(data["elements"], base_filename)
    try:
        gw_num = data["current-event"]
    except:
        gw_num = 0
        print("Season hasn't started yet m8")
    print("Cleaning summary data")
    clean_players(base_filename + 'players_raw.csv', base_filename)
    print("Getting fixtures data")
    fixtures(base_filename)
    if gw_num == 0:
        print("Getting teams data")
        parse_team_data(data["teams"], base_filename)
    print("Extracting player ids")
    id_players(base_filename + 'players_raw.csv', base_filename)
    player_ids = get_player_ids(base_filename)
    num_players = len(data["elements"])
    player_base_filename = base_filename + 'players/'
    gw_base_filename = base_filename + 'gws/'
    print("Extracting player specific data")
    for i in range(num_players):
        player_data = get_individual_player_data(i + 1)
        parse_player_history(player_data["history_past"], player_base_filename,
                             player_ids[i + 1], i + 1)
        parse_player_gw_history(player_data["history"], player_base_filename,
                                player_ids[i + 1], i + 1)
    if gw_num > 0:
        print("Collecting gw scores")
        collect_gw(gw_num, player_base_filename, gw_base_filename)
        print("Merging gw scores")
        merge_gw(gw_num, gw_base_filename)