<commit_before>import json

# Change the name of the file to open to match the query below:
with open('json/20161018-cumulative-player-stats.json') as file:
    alltext = file.readlines()  # Put each line into a list

v = 0  # Rushing
w = 0  # Receiving
x = 0  # Passing
y = 0  # Sacks
z = 0  # Interceptions

for lines in alltext:
    if lines.startswith('{'):
        rawdata = lines
        data = json.loads(rawdata)

        player_list = data['cumulativeplayerstats']['playerstatsentry']

        # try:
        #    for rushing in player_list:
        #        rushing_yards = data['cumulativeplayerstats']['playerstatsentry'][v]['stats']['RushYards']['#text']
        #        player_id = data['cumulativeplayerstats']['playerstatsentry'][v]['player']['ID']
        #        player_firstname = data['cumulativeplayerstats']['playerstatsentry'][v]['player']['FirstName']
        #        player_lastname = data['cumulativeplayerstats']['playerstatsentry'][v]['player']['LastName']
        #        player_position = data['cumulativeplayerstats']['playerstatsentry'][v]['player']['Position']
        #        print((player_id), (player_firstname), (player_lastname), rushing_yards)
        # except KeyError:



        for rushing in player_list:
            try:
                rushing_yards = rushing['stats']['RushYards']['#text']
                player_id = rushing['player']['ID']
                player_firstname = rushing['player']['FirstName']
                player_lastname = rushing['player']['LastName']
                player_position = rushing['player']['Position']
                print((player_id), (player_firstname), (player_lastname), rushing_yards)

            except KeyError:
                continue



                #        rushing_yards = data['cumulativeplayerstats']['playerstatsentry'][1]['stats']['RushYards']['#text']
                #        player_id = data['cumulativeplayerstats']['playerstatsentry'][1]['player']['ID']
                #        player_firstname = data['cumulativeplayerstats']['playerstatsentry'][1]['player']['FirstName']
                #        player_lastname = data['cumulativeplayerstats']['playerstatsentry'][1]['player']['LastName']
                #        player_position = data['cumulativeplayerstats']['playerstatsentry'][1]['player']['Position']
                #        print((player_id), (player_firstname), (player_lastname), rushing_yards)

                #            rushing_yards = data['cumulativeplayerstats']['playerstatsentry'][6]['stats']
                #            print(rushing_yards)

                # TODO: Either do query based on position or write an if / elif statement or try / except if Key Error returned<commit_msg>Clean up weekly_player_stats.py file and remove notes and code from testing<commit_after>import json

# Change the name of the file to open to match the query below:
with open('json/20161018-cumulative-player-stats.json') as file:
    alltext = file.readlines()  # Put each line into a list


for lines in alltext:
    if lines.startswith('{'):
        rawdata = lines
        data = json.loads(rawdata)

        player_list = data['cumulativeplayerstats']['playerstatsentry']

        for rushing in player_list:
            try:
                rushing_yards = rushing['stats']['RushYards']['#text']
                player_id = rushing['player']['ID']
                player_firstname = rushing['player']['FirstName']
                player_lastname = rushing['player']['LastName']
                player_position = rushing['player']['Position']
                print((player_id), (player_firstname), (player_lastname), rushing_yards)

            except KeyError:
                continue
{'fraction_non_alphanumeric': 0.1310326233486115, 'fraction_numerical': 0.007279590186033971, 'mean_word_length': 2.7474747474747474, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1322107', 'n_tokens_mistral': 1014, 'n_tokens_neox': 952, 'n_words': 204}