A Python project for ingesting, cleaning, and analyzing sports data (primarily football) from ESPN and related sources. The project provides tools for building and maintaining a sports database, as well as utilities for data science and analytics workflows.
- Database Ingestion: Scripts to load sports, leagues, teams, athletes, seasons, coaches, events, and more into a MySQL database.
- Data Cleaning: Utilities for deduplicating and enriching athlete and team data, with dynamic loading based on game state, play events, and more.
- Extensible Models: SQLAlchemy ORM models for all major sports entities, allowing for easy expansion and customization.
- API Clients: Clients for fetching up-to-date sports data from ESPN and EA Sports Madden APIs.
- Jupyter Notebooks: Example notebooks for data analysis and exploration.
- Logging: Configurable logging for all scripts and database operations.
- Python 3.12+
- MySQL database
- SQLAlchemy
- pymysql
- Other dependencies as needed (see
pyproject.toml)
-
Clone the repository:
git clone https://github.com/dcott7/fourth-and-py.git cd fourth-and-py -
Install dependencies:
pip install -e . -
Configure the database: Copy
config.ini.exampletoconfig.iniand fill in your MySQL credentials. -
Populate the database:
python scripts/load_db.py
Logging
Logs are written to both stdout and db.log by default. Adjust logging settings in scripts/load_db.py or scripts/cleanup.py.
License
MIT License. See LICENSE for details.
Legal Disclaimer
This project ingests and stores publicly available sports data. While we believe this usage complies with fair use and public data policies, users are responsible for ensuring their own compliance with applicable laws and terms of service. The authors make no guarantees regarding the legality of storing or redistributing this data.