-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoutingPython.py
More file actions
49 lines (46 loc) · 2.56 KB
/
ScoutingPython.py
File metadata and controls
49 lines (46 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import csv
import math
import tbaapiv3client
from tbaapiv3client.rest import ApiException
from pprint import pprint
configuration = tbaapiv3client.Configuration(
host = "https://www.thebluealliance.com/api/v3",
api_key = {
'X-TBA-Auth-Key': 'zpJtTjpTewSyKqYYnjTlzzmq6NzVpc4CrWZzwRrZQvsAoTE3BMnFxekqQkAj1d07'
}
)
with tbaapiv3client.ApiClient(configuration) as api_client:
listOfTeams = ['frc2468', 'frc3005', 'frc118', 'frc148', 'frc3310', 'frc3847', 'frc254', 'frc6328', 'frc2714', 'frc555']
listOfYears = [2022, 2023, 2024]
teamAverages = {}
for team in listOfTeams:
total = 0
tourneyCount = 0
for year in listOfYears:
api_instance = tbaapiv3client.TeamApi(api_client)
team_key = team # str | TBA Team Key, eg `frc254`
year = year # int | Competition Year (or Season). Must be 4 digits.
if_modified_since = 'if_modified_since_example' # str | Value of the `Last-Modified` header in the most recently cached response by the client. (optional)
try:
api_response = api_instance.get_team_events_by_year(team_key, year, if_modified_since=if_modified_since)
everyTourney = []
for val in api_response:
everyTourney.append(val.key)
for tourney in everyTourney:
#print(tourney)
api_response1 = api_instance.get_team_event_status(team_key, tourney, if_modified_since=if_modified_since)
if hasattr(api_response1, 'qual') != False and api_response1.qual is not None and hasattr(api_response1.qual, 'ranking') and hasattr(api_response1.qual.ranking, 'rank') and api_response1.qual is not None and api_response1.qual.ranking.rank is not None:
total += api_response1.qual.ranking.rank
tourneyCount += 1
#print(total)
#total /= len(everyTourney)
except ApiException as e:
print("Exception when calling TeamApi->get_team_events_by_year: %s\n" % e)
total /= tourneyCount
teamAverages[team] = total
#frc 2468, frc 3005, frc 118, frc 148, frc 3310, frc 3847, frc 254, frc 6328, frc 2714, frc 555
#for key, value in teamAverages.items():
#print(key+" has an average qualification ranking of "+str(value))
sorted_teams = sorted(teamAverages.items(), key=lambda x: x[1])
for team, sortedAverages in sorted_teams:
print(team + " has an average qualification ranking of "+str(sortedAverages))