Beispiel #1
0
matches = simplejson.loads(open('all_matches.json').read())
matches = list(set(matches)) # dedupe

##################################START PROCESSING DATA#########################################
with open("final_output.csv", "wb") as csvfile:
    writer = csv.writer(csvfile)
    writer.writerow(headers)
    for match in matches:
        time.sleep(1)
        try:
            m = Match(int(match))
            if m.match_json()['match_status'] == 'forthcoming':
                continue
            if m.result() == '':
                continue
            if m.rain_rule() == 'D/L method':
                duckworth_lewis = 1
            else:
                duckworth_lewis = 0
            try:
                m.team_2()['team_name']
            except KeyError:
                continue
            try:
                m.team_1()['team_name']
            except KeyError:
                continue
            if m.match_json()['international_class_card'] != "":
                match_type_id = m.match_json()['international_class_id']
            else:
                match_type_id = m.match_json()['general_class_id']
Beispiel #2
0
matches = simplejson.loads(open('all_matches.json').read())
matches = list(set(matches))  # dedupe

##################################START PROCESSING DATA#########################################
with open("final_output.csv", "wb") as csvfile:
    writer = csv.writer(csvfile)
    writer.writerow(headers)
    for match in matches:
        time.sleep(1)
        try:
            m = Match(int(match))
            if m.match_json()['match_status'] == 'forthcoming':
                continue
            if m.result() == '':
                continue
            if m.rain_rule() == 'D/L method':
                duckworth_lewis = 1
            else:
                duckworth_lewis = 0
            try:
                m.team_2()['team_name']
            except KeyError:
                continue
            try:
                m.team_1()['team_name']
            except KeyError:
                continue
            if m.match_json()['international_class_card'] != "":
                match_type_id = m.match_json()['international_class_id']
            else:
                match_type_id = m.match_json()['general_class_id']