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)