-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactualize.py
46 lines (35 loc) · 1.39 KB
/
actualize.py
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
import datetime
import io
import os
import etl
year = datetime.date.today()
month = datetime.datetime.now()
current_year = year.year
current_month = month.month
file_path_ranked = f"/home/lucas/Data Science/Project NBA/datasets/combined/ranked_dataset_{current_year - 1}_{current_year}.csv"
file_path_regular = f"/home/lucas/Data Science/Project NBA/datasets/combined/regular_dataset_{current_year - 1}_{current_year}.csv"
blob_name_ranked = f"ranked_dataset_{current_year - 1}_{current_year}.csv"
blob_name_regular = f"regular_dataset_{current_year - 1}_{current_year}.csv"
## To be sure the stats on the November 10th 2025 are labelled with 2025-2026, as well as the stats on the March 10th 2026
if current_month >= 8:
current_year = current_year + 1
regular_df, advanced_df, shooting_splits_df = etl.create_yearly_dataframes(current_year)
full_dataset, full_dataset_ranked = etl.transform_data(
regular_df, advanced_df, shooting_splits_df
)
if os.path.exists(file_path_regular):
os.remove(file_path_regular)
if os.path.exists(file_path_ranked):
os.remove(file_path_ranked)
etl.export_data_to_csv(current_year - 1, full_dataset, full_dataset_ranked)
etl.upload_to_bucket(
"nba_dashboard_files",
file_path_regular,
blob_name_regular,
)
etl.upload_to_bucket(
"nba_dashboard_files",
file_path_ranked,
blob_name_ranked,
)
print(f"upload for the year {current_year} done")