This project builds an ETL (Extract, Transform, Load) pipeline that processes Spotify and enhances them with musical data from the Wikidata API. It includes data cleaning, fuzzy matching, API integration and in-depth analysis, orchestrated with Apache Airflow and stored in a PostgreSQL database.
The pipeline performs the following steps:
-
Extract:
- Reads raw Spotify data from a CSV file.
- Extracts Grammy nomination data from a PostgreSQL database.
- Makes requests to the API to extract the data.
-
Transform:
- Cleans and preprocesses Spotify, Grammy and the API datasets.
- Merges the datasets to align Spotify tracks with Grammy nominations.
- Enriches the merged dataset with metadata from the Wikidata API.
-
Load:
- Stores the final enriched dataset in a PostgreSQL database.
-
Store (optional):
- Uploads the results to Google Drive.
Workshop_002/
├── airflow/ # Airflow-related files
├── dag/ # Airflow DAG
│ └── dag_workshop.py # Main DAG file
├── data/ # Data storaged
├── notebooks/ # Jupyter notebooks
├── src/ # Python scripts for the ETL pipeline
│ ├── extract/
│ │ ├── extract_api.py
│ │ ├── extract_grammy.py
│ │ ├── extract_spotify.py
│ ├── load/
│ │ ├── load.py
│ │ ├── store.py
│ ├── transform/
│ │ ├── merge.py
│ │ ├── transform_api.py
│ │ ├── transform_grammy.py
│ │ ├── transform_spotify.py
├── venv/ # Virtual environment
├── .gitignore # Git ignore file
└── requirements.txt # Project dependencies
- Python 3.8+
- Apache Airflow
- PostgreSQL
- Google Drive API credentials (optional)
git clone <repository-url>python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtexport AIRFLOW_HOME=$(pwd)/airflow
airflow db init
airflow webserver --port 8080
airflow schedulerCreate a file credentials.json with the following structure:
{
"postgresql": {
"username": "your_username",
"password": "your_password",
"host": "your_host",
"port": "your_port",
"database": "your_database"
}Ensure this file is included in .gitignore.
- Place the raw Spotify dataset (
spotify_dataset.csv) indata. - Ensure the Grammy nominations data is stored in your PostgreSQL database under the table
grammy_raw_data.
Open your browser and go to http://localhost:8080.
Default credentials:
- Username:
airflow - Password:
airflow
- Locate the
etl_pipelineDAG. - Turn it On and click "Trigger DAG".
- Use the Airflow UI to track task status.
- Logs are available under
airflow/logs/.
- Final dataset saved in PostgreSQL under
data_pipeline. - If implemented, data is uploaded to Google Drive.
The etl_pipeline DAG includes:
task_extract_spotifytask_extract_grammytask_extract_apitask_transform_spotifytask_transform_grammytask_transform_apitask_mergetask_loadtask_store_to_drive(optional)
Key packages in requirements.txt include:
pandassqlalchemyapache-airflow