XLSForm to Registro (Data Dictionary Generator)
Herramienta autónoma en Python para convertir cualquier formulario XLSForm estándar (.xlsx o .xls) de KoboToolbox, ODK o Enketo en un Diseño de Registro institucional (Diccionario de Datos / Codebook) en formato Excel, con formato editorial profesional, traductor semántico de universos, soporte para estándar estadístico estilo INDEC / EPH / CEPAL y hojas complementarias para catálogos extensos.
Características principales
- 100% basado en el estándar XLSForm: Lee directamente
survey,choices,settingsy (opcionalmente)changelog, sin conexión a internet ni bases de datos. - Dos perfiles editoriales (
--profile classic|indec):classic(por defecto, retrocompatible v1): 5 columnas clásicas (Nombre,Etiqueta,Valor,Etiqueta de valor,Universo de referencia).indec(estándar estadístico): agrega Hoja 0Portada(metadatos, mapa relacional de bases con claves_uuid/_submission__uuid/_parent_index, índice de catálogos,changelogy convenciones) + 8 columnas institucionales (Tipo / Formato,Reglas / Validación,Observaciones / Notas) e hipervínculos internos de navegación.
- Detección automática de entidades y
repeat:- Cada bloque
begin_repeatgenera una hoja independiente y propaga automáticamente su condiciónrelevanta todas las variables hijas.
- Cada bloque
- Traductor semántico de
relevantyconstraint:- Traduce reglas complejas (
<=,>=,selected('1 6 7', ${var}),not(selected(...)), controles de vacío= ''/!= '',count-selected,contains) y resuelve los códigos a sus etiquetas reales (ej.condicion_actividad = 1 (Ocupado/a)).
- Traduce reglas complejas (
- Soporte real de
choice_filtery listas dinámicas:- Filtra catálogos estáticos (
tipo = 'banco') para mostrar únicamente las opciones pertinentes en cada pregunta y reconoce listas dinámicas de repeats (select_one ${var}).
- Filtra catálogos estáticos (
- Manejo inteligente de variables
calculate(--calculate-mode):none(default),derived(documenta solo variables analíticas/construidas en una sección diferenciada al final de cada base, omitiendo auxiliares técnicostok_*,*_lbl,*_pregunta) oall.
- Calidad editorial en Excel (
openpyxl):- Alturas de fila dinámicas (sin recortes en textos multilínea o celdas combinadas).
- Barras de sección diferenciadas, paneles inmovilizados (
freeze_panes), hipervínculos a catálogos y configuración de impresión apaisada lista para exportar a PDF. - Manejo seguro de
No aplica(--na-code 0|blanco|none): evita colisiones automáticamente si el código0ya existe en la pregunta.
Instalación
pip install xlsform-to-registro
Requiere Python 3.10 o superior (pandas y openpyxl).
Uso desde la Línea de Comandos (CLI)
# Uso básico (perfil classic, 5 columnas, retrocompatible)
xlsform-to-registro ruta/a/tu_formulario.xlsx
# Diseño de Registro estándar estadístico (Portada + 8 columnas + variables derivadas)
xlsform-to-registro formulario.xlsx -o diseño_registro_indec.xlsx --profile indec --calculate-mode derived
# Especificar idioma, hoja principal y convención de No aplica en blanco (Kobo/ODK)
xlsform-to-registro formulario.xlsx --profile indec --lang es --main-sheet-name base_hogar --na-code blanco
# Personalizar color de encabezados y umbral de catálogos anexos
xlsform-to-registro formulario.xlsx --header-color 1F4E78 --catalogue-threshold 20
(También se puede invocar como módulo: python -m xlsform_to_registro ruta/a/tu_formulario.xlsx).
Opciones disponibles en CLI
| Argumento | Descripción | Valor por defecto |
|---|---|---|
xlsform |
Ruta al archivo XLSForm de entrada (.xlsx o .xls). |
(Obligatorio) |
-o, --output |
Ruta del archivo Excel de salida. | diseño_registro_<nombre>.xlsx |
--profile |
Perfil editorial: classic (5 columnas) o indec (Portada + 8 columnas). |
classic |
--lang |
Idioma o sufijo de etiqueta a utilizar (ej. es, Español, en). |
Primer label disponible |
--header-color |
Color hexadecimal de encabezados (sin #). |
64b692 (classic) / 1F4E78 (indec) |
--calculate-mode |
Manejo de calculate: none, derived (solo analíticas) o all. |
none |
--include-calculate |
Alias retrocompatible de --calculate-mode all. |
False |
--include-notes |
Incluye filas de tipo note. |
False |
--include-metadata |
Incluye metadatos de sistema (start, end, deviceid, username, audit). |
False |
--catalogue-threshold |
Umbral de opciones a partir del cual una lista pasa a hoja catalogo_*. |
30 |
--main-sheet-name |
Nombre explícito de la hoja principal (prioritario sobre settings). |
form_id de settings o base_hogar |
--na-code |
Convención de No aplica en preguntas con salto: 0 (fallback seguro si 0 existe), blanco o none. |
0 |
--no-na-code |
Alias retrocompatible de --na-code none. |
False |
Uso como Librería en Python
from xlsform_to_registro import XLSFormToRegistro
converter = XLSFormToRegistro(
xlsform_path="tu_formulario.xlsx",
profile="indec",
calculate_mode="derived",
na_code="0",
lang="es",
catalogue_threshold=30,
custom_replacements={
"nombre": "la persona entrevistada",
"organizacion": "la organización comunitaria",
},
)
output_file = converter.to_excel("diseño_registro_modelo.xlsx")
print(f"Generado exitosamente en: {output_file}")
Estructura del Proyecto
xlsform-to-registro/
├── .github/workflows/
│ ├── ci.yml # Ruff lint + unittest en Python 3.10–3.13
│ └── publish.yml # Publicación a PyPI con Trusted Publishing
├── src/xlsform_to_registro/
│ ├── __init__.py # Exporta XLSFormToRegistro y __version__
│ ├── __main__.py # Soporte para python -m xlsform_to_registro
│ ├── cli.py # Interfaz de línea de comandos
│ ├── generator.py # Orquestador de parsing y generación Excel
│ ├── core/
│ │ ├── parser.py # Lectura de survey, choices, settings y changelog
│ │ ├── schema.py # Dataclasses del modelo lógico
│ │ ├── relevant_parser.py # Traductor semántico de relevant y constraint
│ │ ├── choice_filter.py # Evaluación segura de choice_filter y listas dinámicas
│ │ └── text_cleaner.py # Limpieza de HTML, Markdown y placeholders
│ └── exporters/
│ └── excel_styler.py # Motor editorial openpyxl (classic e indec)
├── tests/ # Suite de tests unitarios (unittest)
├── CHANGELOG.md # Historial de versiones
├── pyproject.toml # Configuración de paquete (Hatchling) y Ruff
├── LICENSE # Licencia MIT
└── README.md
Licencia
Este proyecto se distribuye bajo la licencia MIT.
Metadata
Release files for xlsform-to-registro 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xlsform_to_registro-2.0.0.tar.gz | 69.7 kB | With provenance | Details for xlsform_to_registro-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xlsform_to_registro-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for xlsform_to_registro-2.0.0-py3-none-any.whl |
Total release size: 102.5 kB
Release files / xlsform_to_registro-2.0.0.tar.gz
| Download URL | xlsform_to_registro-2.0.0.tar.gz |
|---|---|
| Size | 69.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c518aa0380aa561c80d882f4e6f8384c9dcb3d064d8809f62bf829c5a0a514d4
|
|
BLAKE2b-256 checksum How to use checksums |
983289af2cac071445a1825e9a35c6b75a44855203898405f5808d46b976569d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logRelease files / xlsform_to_registro-2.0.0-py3-none-any.whl
| Download URL | xlsform_to_registro-2.0.0-py3-none-any.whl |
|---|---|
| Size | 32.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c51510c1546095b23ad133b1f46de89ca533904c6be9959112d3143869980336
|
|
BLAKE2b-256 checksum How to use checksums |
528fb317faeae57252486b950baadee3307bcfc4ddd1d6e44e3c8f1b4001227c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logSecurity for xlsform-to-registro 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for xlsform_to_registro-2.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.