Python ETL and dimensional Power BI model for Moroccan coworking spaces and marketing agencies.
# Morocco Business Intelligence ETL Pipeline
A Python data engineering project that cleans Google Maps datasets for coworking spaces and marketing agencies in Morocco, resolves data-quality issues, and builds a dimensional Excel model ready for Power BI.
## Pipeline
1. `clean_data.py` loads the raw coworking and marketing CSV files.
2. It removes duplicates and invalid records, normalizes Moroccan city names, validates coordinates, and derives analytical columns.
3. It writes cleaned CSV files and a report of rows that still require manual review.
4. `build_dw.py` combines the cleaned data into a star-schema workbook for Power BI.
## Outputs
- `coworking_clean.csv`
- `marketing_agency_clean.csv`
- `output/manual_fixes_report.txt`
- `output/manual_fixes_rows.csv` when manual issues exist
- `DW_Tables_PowerBI.xlsx`
The workbook contains `fact_table`, `dim_city`, `dim_category`, `dim_status`, and `dim_source` sheets. The fact table includes ratings, review counts, location coordinates, category counts, competitor counts, advertising status, and closure indicators.
## Requirements
- Python 3.9+
- pandas
- openpyxl
```bash
python -m venv .venv
```
On Windows:
```powershell
.venv\Scripts\Activate.ps1
pip install pandas openpyxl
```
## Input Files
Place these raw files in the project root before running the cleaning stage:
```text
Coworking Space In Morocco.csv
Marketing Agency In Morocco.csv
```
The raw input files are not included in the current project snapshot.
## Run
```bash
python clean_data.py
python build_dw.py
```
Run both commands from the project root because `build_dw.py` reads the cleaned CSV files using relative paths.
## Power BI Relationships
```text
fact_table.city_id -> dim_city.city_id
fact_table.category_id -> dim_category.category_id
fact_table.status_id -> dim_status.status_id
fact_table.source_id -> dim_source.source_id
```
## Data Quality Rules
- Deduplicate records by Google Maps `place_id`.
- Keep Moroccan records usi …