-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_exporter.py
113 lines (97 loc) · 4.59 KB
/
data_exporter.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
from os.path import abspath
from basketball_reference_web_scraper import client
from basketball_reference_web_scraper.data import OutputType
def main():
print("\n#######################################################################")
print("#######################################################################")
print("######################### NBA Report exporter #########################")
print("#######################################################################")
print("#######################################################################\n")
while (True):
print(
"1. Players box scores by a date\
\n2. Players season statistics for a season\
\n3. Players advanced season statistics for a season\
\n4. All Team box scores by a date\
\n5. Schedule for a season\
\n6. Exit"
)
reportObject = input("\nPlease select a option: ")
# Players box scores by a date
if (reportObject == "1"):
inputDate = input("\nEnter a date (use this format 1-1-2018): ")
fileName = "all-player-box-report-" + inputDate + ".csv"
dateList = inputDate.split("-")
print("Exporting report please wait..........")
# Call Export function
client.player_box_scores(
day=dateList[0],
month=dateList[1],
year=dateList[2],
output_type=OutputType.CSV,
output_file_path="exported_files/" + fileName
)
print("Report exported at: " + abspath("exported_files/" + fileName) + "!!\n\n")
# Players season statistics for a season
elif (reportObject == "2"):
endYear = input("\nEnter season end year: ")
fileName = "all-player-season-report-" + endYear + ".csv"
print("Exporting report please wait..........")
# Call Export function
client.players_season_totals(
season_end_year=endYear,
output_type=OutputType.CSV,
output_file_path="exported_files/" + fileName
)
print("Report exported at: " + abspath("exported_files/" + fileName) + "!!\n\n")
# Players advanced season statistics for a season
elif (reportObject == "3"):
endYear = input("\nEnter season end year: ")
fileName = "all-player-advanced-season-report-" + endYear + ".csv"
print("Exporting report please wait..........")
# Call Export function
client.players_advanced_season_totals(
season_end_year=endYear,
output_type=OutputType.CSV,
output_file_path="exported_files/" + fileName
)
print("Report exported at: " + abspath("exported_files/" + fileName) + "!!\n\n")
# All Team box scores by a date
elif (reportObject == "4"):
inputDate = input("\nEnter a date (use this format 1-1-2018): ")
fileName = "all-team-report-" + inputDate + ".csv"
dateList = inputDate.split("-")
print("Exporting report please wait..........")
# Call Export function
client.team_box_scores(
day=dateList[0],
month=dateList[1],
year=dateList[2],
output_type=OutputType.CSV,
output_file_path="exported_files/" + fileName
)
print("Report exported at: " + abspath("exported_files/" + fileName) + "!!\n\n")
# Schedule for a season
elif (reportObject == "5"):
endYear = input("\nEnter season end year: ")
fileName = "season-schedule-" + endYear + ".csv"
print("Exporting report please wait..........")
# Call Export function
client.season_schedule(
season_end_year=endYear,
output_type=OutputType.CSV,
output_file_path="exported_files/" + fileName
)
print("Report exported at: " + abspath("exported_files/" + fileName) + "!!\n\n")
# Exit
elif (reportObject == "6"):
print("\n#######################################################################")
print("################################# Bye #################################")
print("#######################################################################\n")
break
# Error
else:
print("Invalid option!!\n\n")
################# Main #################
if __name__ == '__main__':
main()