End-to-end ETL pipeline for South African load shedding data using Python, SQL and Apache Airflow
# π South African Load Shedding ETL Pipeline
An end-to-end data engineering pipeline that **extracts**, **transforms**, and **loads** South African load shedding schedule data from the EskomSePush API into a structured analytical database β orchestrated with Apache Airflow and scheduled to run daily.
---
## π Architecture
```
EskomSePush API
β
βΌ
[Extract] βββΆ data/raw/ (raw JSON)
β
βΌ
[Transform] βββΆ data/processed/ (clean CSVs)
β
βΌ
[Load] βββΆ SQLite DB (star schema)
β
βΌ
[Airflow DAG] ββ scheduled daily
```
---
## ποΈ Project Structure
```
loadshedding_etl/
βββ etl/
β βββ extract.py # API ingestion
β βββ transform.py # Data cleaning & normalization
β βββ load.py # Database loading
βββ dags/
β βββ loadshedding_dag.py # Airflow DAG definition
βββ sql/
β βββ create_tables.sql # Schema definition
β βββ analysis_queries.sql # Analytical SQL queries
βββ data/
β βββ raw/ # Raw API responses (gitignored)
β βββ processed/ # Cleaned CSVs (gitignored)
βββ notebooks/
β βββ exploration.ipynb # EDA & findings
βββ tests/
β βββ test_transform.py # Unit tests
βββ .github/workflows/
β βββ ci.yml # GitHub Actions CI
βββ requirements.txt
βββ .env.example
βββ README.md
```
---
## βοΈ Setup
### 1. Clone the repository
```bash
git clone
github.com
cd loadshedding-etl
```
### 2. Create virtual environment
```bash
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
```
### 3. Install dependencies
```bash
pip install -r requirements.txt
```
### 4. Configure environment variables
```bash
cp .env.example .env
# Add your EskomSePush API key to .env
```
### 5. Initialise the database
```bash
python -m etl.load --init
```
### 6. Run the pipeline manually
```bash
python -m etl.extract
python -m etl.transform
python -m etl.load
```
---
## ποΈ Database Schema
The pipeline loads data i β¦