This project provides a web application for analyzing and visualizing FC Barcelona's match data. The application is built with Streamlit, scrapes match data from WhoScored, processes and stores it in MongoDB, and displays it in a streamlined dashboard.
- Data Scraping: Scrapes FC Barcelona's match data from WhoScored.
- MongoDB Storage: Stores all match, team, player, and event data in MongoDB.
- Data Visualization: Interactive visualizations including pass networks, shot maps, match momentum, and team statistics.
- Streamlit Interface: Simple and interactive web dashboard for viewing and analyzing match data.
- Python 3.7+
- MongoDB instance
- Chrome WebDriver (for Selenium)
-
Clone the repository:
git clone https://github.com/yusufwa7ied/FC-Barcelona-Match-Reports.git cd fc-barcelona-dashboard
-
Set up environment variables:
- Create a
.env
file in the project root and add your MongoDB URI:MONGO_URI="your_mongodb_connection_string"
- Create a
-
Install dependencies:
pip install -r requirements.txt
-
Data Scraping:
- To scrape data and add it to your MongoDB, run:
python scraper.py
- This script only scrapes new matches not already in the database.
- To scrape data and add it to your MongoDB, run:
-
Start the Streamlit App:
- To launch the dashboard, run:
streamlit run dashboard.py
- Access the dashboard at
http://localhost:8501
.
- To launch the dashboard, run:
scraper.py
: Web scraping script that fetches match data from WhoScored.data_loader.py
: Loads data from MongoDB into DataFrames.dashboard.py
: Streamlit app for displaying match data.visualizations.py
: Contains functions for visualizations used in the app.config.toml
: Configuration for Streamlit app styling..env
: Environment variables.
List of libraries in requirements.txt
:
pandas
numpy
selenium
pymongo
beautifulsoup4
streamlit
mplsoccer
matplotlib
python-dotenv
- Environment Variables: Ensure
.env
is added to.gitignore
to keep credentials secure. - Chrome WebDriver: Ensure compatibility with your Chrome version. You may need to update the
webdriver.Chrome()
configuration inscraper.py
based on your setup.