29 lines
828 B
Python
29 lines
828 B
Python
import asyncio
|
|
import datetime
|
|
import sys
|
|
|
|
import pandas as pd
|
|
from db_calls import db_get
|
|
|
|
|
|
async def main(args):
|
|
start_time = datetime.datetime.now()
|
|
print(f'Pulling in season 9 scoring plays...')
|
|
play_query = await db_get(
|
|
'plays',
|
|
api_ver=3,
|
|
params=[('season', 9), ('s_type', 'regular'), ('limit', 100000), ('short_output', True)]
|
|
)
|
|
p_run_time = datetime.datetime.now() - start_time
|
|
print(f'Pulled in {play_query["count"]} total plays in {round(p_run_time.total_seconds())} seconds')
|
|
|
|
s_plays = pd.DataFrame(play_query['plays'])
|
|
print(f'Built the dataframe\nSaving to csv...')
|
|
|
|
s_plays.to_csv('regular-season-plays.csv', encoding='utf-8', index=False)
|
|
print('Saved to regular-season-plays.csv')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(main(sys.argv[1:]))
|