mirror of
https://github.com/nprasad2077/nbaStats.git
synced 2026-11-05 01:25:48 +00:00
change scraper to output new json and csv for each team
This commit is contained in:
1 parent
50af7d9fc8
commit
a08f9b6117
1 file changed
+8
-5
+8
-5
@@ -56,17 +56,17 @@ for team in teams:
|
||||
|
||||
# locate current directory
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
# CSV file
|
||||
csv_output_path = os.path.join(script_dir, '..', 'data', 'output.csv')
|
||||
csv_output_path = os.path.join(script_dir, '..', 'data', f'{team}_{season}_output.csv')
|
||||
with open(csv_output_path, "w", newline="") as csvfile:
|
||||
writer = csv.DictWriter(csvfile, fieldnames =headers)
|
||||
writer = csv.DictWriter(csvfile, fieldnames=headers)
|
||||
writer.writeheader()
|
||||
for row in data:
|
||||
writer.writerow(row)
|
||||
|
||||
# Save as JSON
|
||||
json_output_path = os.path.join(script_dir, '..', 'data', 'output.json')
|
||||
json_output_path = os.path.join(script_dir, '..', 'data', f'{team}_{season}_output.json')
|
||||
with open(json_output_path, 'w') as jsonfile:
|
||||
json.dump(data, jsonfile)
|
||||
|
||||
@@ -103,4 +103,7 @@ for team in teams:
|
||||
team=row['team'],
|
||||
season=row['season'],
|
||||
)
|
||||
player_data.save()
|
||||
player_data.save()
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user