From 98e375682a50f3cdeddc8e6af022d1e8d12f608d Mon Sep 17 00:00:00 2001 From: Rasmus Luha Date: Thu, 17 Mar 2022 13:48:15 +0200 Subject: file name fixes --- api/utils.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 api/utils.py (limited to 'api/utils.py') diff --git a/api/utils.py b/api/utils.py new file mode 100644 index 0000000..c04bdf1 --- /dev/null +++ b/api/utils.py @@ -0,0 +1,18 @@ +import pandas as pd + +# Making relative paths. On windows slashes would be backwards +# It is probably not the best way. +relPathTeams = "../AllAboutData/Data/NBAteams.csv" +relPathPlayers = "../AllAboutData/Data/Players/" + +def getTeamNames(): + ''' + Returns dictionary with fetched teams' names as keys + and full_names as values. + ''' + + teamsDf = pd.read_csv(relPathTeams).to_dict() + team_names = {} + for el in range(len(teamsDf["name"])): + team_names.update({teamsDf["name"][el] : teamsDf["full_name"][el]}) + return team_names -- cgit v1.2.3