Skip to content

Instantly share code, notes, and snippets.

@MC42
Created May 29, 2017 01:28
Show Gist options
  • Select an option

  • Save MC42/bb0a724ca9ba80befe335918e1ff1ba1 to your computer and use it in GitHub Desktop.

Select an option

Save MC42/bb0a724ca9ba80befe335918e1ff1ba1 to your computer and use it in GitHub Desktop.

Revisions

  1. MC42 created this gist May 29, 2017.
    30 changes: 30 additions & 0 deletions awardmath.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    import csv
    import requests
    from tqdm import tqdm
    baseURL = 'http://www.thebluealliance.com/api/v2/'
    header = {'X-TBA-App-Id': 'tjf:thepythonalliance:award_math'}

    most = ["",0]
    rows = []
    with open('teams.csv', 'r') as csvfile:
    spamreader = csv.reader(csvfile, delimiter=',')
    for row in spamreader:
    rows.append(row)

    for row in tqdm(rows):
    if (len(row)) > 0:
    myRequest = (baseURL + 'team/' + row[0] + "/history/awards")
    response = requests.get(myRequest, headers=header)
    jsonified = response.json()
    total = 0
    for award in jsonified:
    if award['award_type'] == 22:
    total+=1

    if total > most[1]:
    most[0] = row[0]
    most[1] = total
    print(most)