update models to decimal and account for null values

This commit is contained in:
nprasad2077 committed 2023-04-18 15:06:13 -05:00
1 parent 3de2377dd3
commit 1ca063cdcb
7 files changed
+374 -29

No files matched your search

+8 -2
View File
@@ -33,15 +33,19 @@ rows = table.find("tbody").find_all("tr")
# Extract coloumn headers
headers = [col.text.strip() for col in header_row.find_all("th")][1:]
headers.extend(['team', 'season']) # Add 'team' and 'season' fields to headers
# extract rows as dictionaries
# Extract rows as dictionaries
data = []
for row in rows:
cols = row.find_all("td")
cols = [col.text.strip() for col in cols]
row_dict = dict(zip(headers, cols))
row_dict = {header: (None if col == "" else col) for header, col in zip(headers, cols)}
row_dict['team'] = team
row_dict['season'] = season
data.append(row_dict)
# locate current directory
script_dir = os.path.dirname(os.path.abspath(__file__))
@@ -88,5 +92,7 @@ for row in data:
TOV=row['TOV'],
PF=row['PF'],
PTS=row['PTS'],
team=row['team'],
season=row['season'],
)
player_data.save()