|
1 | | -# Scripts 10/10 para el dataset demográfico |
2 | | - |
3 | | -Este paquete sustituye tus scripts mínimos por un pipeline reproducible y mantenible. |
4 | | - |
5 | | -## Qué incluye |
6 | | - |
7 | | -- `scripts/validate_dataset.py`: valida estructura, duplicados y coherencia aritmética. |
8 | | -- `scripts/build_indicators.py`: calcula indicadores derivados y genera resúmenes. |
9 | | -- `scripts/build_atlas_data.py`: construye el JSON/CSV para el atlas. |
10 | | -- `scripts/generate_research_pages.py`: crea páginas automáticas de investigación con rankings. |
11 | | -- `scripts/build_site.py`: genera el sitio HTML estático con índice, perfiles por país y comparativas. |
12 | | -- `scripts/run_all.py`: ejecuta todo en el orden correcto. |
13 | | -- `scripts/common.py`: utilidades compartidas, mapeo ISO3 y regiones. |
14 | | - |
15 | | -## Estructura esperada del repositorio |
16 | | - |
17 | | -```text |
18 | | -repo/ |
19 | | -├─ data/ |
20 | | -│ └─ dataset.csv |
21 | | -├─ docs/ |
22 | | -│ └─ assets/atlas.css |
23 | | -└─ scripts/ |
24 | | - ├─ common.py |
25 | | - ├─ validate_dataset.py |
26 | | - ├─ build_indicators.py |
27 | | - ├─ build_atlas_data.py |
28 | | - ├─ generate_research_pages.py |
29 | | - ├─ build_site.py |
30 | | - └─ run_all.py |
| 1 | +# Scripts del micrositio demográfico |
| 2 | + |
| 3 | +## Descripción |
| 4 | + |
| 5 | +Scripts Python para generar el micrositio estático a partir del archivo `data/dataset.csv`. |
| 6 | + |
| 7 | +## Estructura generada |
| 8 | + |
| 9 | +Al ejecutar el pipeline completo se produce: |
| 10 | + |
| 11 | +``` |
| 12 | +docs/ |
| 13 | +├── index.html # portada del sitio |
| 14 | +├── assets/ |
| 15 | +│ ├── style.css |
| 16 | +│ └── app.js |
| 17 | +├── pages/ |
| 18 | +│ ├── countries.html # índice de países |
| 19 | +│ ├── country-{país}.html # ficha por país (11) |
| 20 | +│ ├── country-{país}-year-{año}.html # ficha país×año (44) |
| 21 | +│ ├── years.html # índice de años |
| 22 | +│ ├── year-{año}.html # ficha por año (4) |
| 23 | +│ ├── indicators.html # índice de indicadores |
| 24 | +│ ├── indicator-{ind}.html # ficha por indicador (12) |
| 25 | +│ ├── comparisons.html # índice de comparaciones |
| 26 | +│ ├── compare-{a}-vs-{b}-{ind}.html # comparación bilateral (660) |
| 27 | +│ └── research-questions/ |
| 28 | +│ ├── index.html # índice de preguntas |
| 29 | +│ ├── que-paises-*.html # preguntas globales (4) |
| 30 | +│ └── como-*-en-{país}.html # preguntas por país (33) |
| 31 | +├── atlas/ |
| 32 | +│ └── data/ |
| 33 | +│ ├── atlas_data.json |
| 34 | +│ ├── atlas_metadata.json |
| 35 | +│ └── atlas_data_with_indicators.csv |
| 36 | +└── data/ |
| 37 | + ├── dataset_with_indicators.csv |
| 38 | + ├── indicators_summary_by_country.csv |
| 39 | + ├── indicators_summary_by_year.csv |
| 40 | + └── latest_snapshot.csv |
31 | 41 | ``` |
32 | 42 |
|
33 | | -## Ejecución rápida |
| 43 | +## Scripts |
| 44 | + |
| 45 | +| Script | Función | |
| 46 | +|---|---| |
| 47 | +| `validate_dataset.py` | Valida columnas, tipos y coherencia del CSV | |
| 48 | +| `build_indicators.py` | Calcula indicadores y genera CSVs en `data/` | |
| 49 | +| `build_atlas_data.py` | Genera JSON para el atlas interactivo en `docs/atlas/data/` | |
| 50 | +| `build_site.py` | Genera las páginas HTML en `docs/pages/` | |
| 51 | +| `generate_research_pages.py` | Genera las preguntas de investigación en `docs/pages/research-questions/` | |
| 52 | +| `run_all.py` | Ejecuta el pipeline completo en orden | |
| 53 | +| `common.py` | Funciones compartidas (lectura, slugify, indicadores, etc.) | |
| 54 | + |
| 55 | +## Ejecución |
| 56 | + |
| 57 | +### Pipeline completo |
34 | 58 |
|
35 | 59 | ```bash |
36 | 60 | python scripts/run_all.py |
37 | 61 | ``` |
38 | 62 |
|
39 | | -## Ejecución paso a paso |
| 63 | +### Scripts individuales |
40 | 64 |
|
41 | 65 | ```bash |
42 | 66 | python scripts/validate_dataset.py |
43 | 67 | python scripts/build_indicators.py |
44 | 68 | python scripts/build_atlas_data.py |
45 | | -python scripts/generate_research_pages.py |
46 | 69 | python scripts/build_site.py |
| 70 | +python scripts/generate_research_pages.py |
| 71 | +``` |
| 72 | + |
| 73 | +## Requisitos |
| 74 | + |
47 | 75 | ``` |
| 76 | +pip install -r requirements.txt |
| 77 | +``` |
| 78 | + |
| 79 | +## Notas de diseño |
48 | 80 |
|
49 | | -## Archivos generados |
50 | | - |
51 | | -### En `data/` |
52 | | -- `dataset_with_indicators.csv` |
53 | | -- `indicators_summary_by_country.csv` |
54 | | -- `indicators_summary_by_year.csv` |
55 | | -- `latest_snapshot.csv` |
56 | | - |
57 | | -### En `docs/atlas/data/` |
58 | | -- `atlas_data.json` |
59 | | -- `atlas_metadata.json` |
60 | | -- `atlas_data_with_indicators.csv` |
61 | | - |
62 | | -### En `docs/` |
63 | | -- `index.html` |
64 | | -- `countries/*.html` |
65 | | -- `compare/*.html` |
66 | | -- `research-questions/*.html` |
67 | | - |
68 | | -## Mejora real frente a tus scripts originales |
69 | | - |
70 | | -- ya no hay placeholders |
71 | | -- ya no depende de edición manual |
72 | | -- separa validación, indicadores, atlas y sitio |
73 | | -- añade ISO3 y región |
74 | | -- genera resúmenes y rankings |
75 | | -- deja un pipeline reproducible para GitHub Pages |
| 81 | +- Todos los scripts leen `data/dataset.csv` por defecto (configurable con `--input`). |
| 82 | +- El directorio de salida por defecto es `docs/` (configurable con `--docs-dir`). |
| 83 | +- Las páginas generadas usan `assets/style.css` y `assets/app.js` del sitio real. |
| 84 | +- La navegación de todas las páginas es consistente con la estructura `docs/pages/`. |
| 85 | +- Las comparaciones bilaterales cubren los 11 países × 12 indicadores = 660 páginas. |
0 commit comments