pytabify
Datos tabulares para pruebas en Python y Robot Framework.
pytabify lee CSV, JSON y XLSX como tablas de filas planas. Cada columna es un campo y cada fila permite consultar sus valores directamente: row.name o row["name"]. Puedes actualizar celdas, añadir columnas y guardar la tabla en cualquiera de los formatos compatibles.
Instalación
pip install pytabify
Para ejecutar pruebas con Robot Framework, instala también robotframework en tu proyecto.
Un CSV, una tabla
Archivo casos.csv:
nombre,cp,cotizacion
Ana,01000,
Luis,64000,
from pytabify import DataTableCreator, DataTableSaver
table = DataTableCreator.from_file("casos.csv")
row = table[0]
assert row.nombre == row["nombre"] == "Ana"
assert row.cp == "01000" # CSV conserva texto, incluidos los ceros iniciales
assert row.cotizacion == ""
row.cotizacion = "COT-123"
table[1]["cotizacion"] = "COT-456"
DataTableSaver.into_csv(table, "casos_actualizados.csv")
La escritura en memoria no guarda el archivo automáticamente. Llama a into_csv cuando quieras exportar el estado de la tabla. Si una prueba falla antes de esa llamada, ese CSV de salida no se crea; para conservar cada folio en el momento de obtenerlo hace falta un registro de resultados independiente.
En Robot Framework
*** Settings ***
Library pytabify.robot.PyTabifyLibrary WITH NAME PyTabify
*** Test Cases ***
Leer un caso
${table}= PyTabify.Create Data Table From File casos.csv
${row}= PyTabify.Get Data Table Row ${table} 0
Should Be Equal ${row.nombre} Ana
Should Be Equal ${row}[cp] 01000
IF $row.cotizacion == ''
Log Aún no tiene cotización
END
${table}= PyTabify.Set Data Table Value ${table} 0 cotizacion COT-123
PyTabify.Save Data Table To Csv ${table} casos_actualizados.csv
En expresiones IF, Robot puede evaluar el valor de $row.cotizacion directamente; no necesitas una propiedad .value ni Evaluate.
Datos desde Python
table = DataTableCreator.from_records(
[{"nombre": "Ana", "activo": True}, {"nombre": "Luis", "activo": False}]
)
assert table[0].activo is True
table[0]["folio"] = "F-1"
assert table[1].folio is None # Las columnas nuevas se agregan a todas las filas
from_records conserva tipos de Python, como bool, int y None. En CSV los valores se leen como cadenas; para un encabezado que no sea identificador de Python, o que coincida con un método como to_dict, usa row["nombre de columna"].
Formatos y reglas
| Entrada | Valores leídos | Opciones |
|---|---|---|
| CSV | Cadenas, también para números y celdas vacías | encoding="utf-8" |
| JSON | Tipos representados en JSON | encoding="utf-8" |
| XLSX | Tipos entregados por openpyxl | sheet_name="Hoja1" |
Las filas deben compartir columnas. Los encabezados vacíos o repetidos y las filas CSV con más o menos celdas se rechazan con un error que identifica el problema. Las columnas se mantienen en orden; agregar una columna asigna None a las demás filas.
Consulta la guía de inicio, la API de tablas y los ejemplos de Robot para más casos.
Desarrollo
poetry install
poetry run ruff check .
poetry run ruff format --check .
poetry run mypy src/pytabify
poetry run lint-imports
poetry run pytest
poetry run mkdocs build --strict
La documentación se publica desde main con GitHub Actions. Las versiones de PyPI se publican desde una GitHub Release cuyo tag coincida con v seguido de la versión de pyproject.toml, mediante Trusted Publishing.
Licencia
MIT. Consulta LICENSE.
Release files for pytabify 3.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 | |
|---|---|---|---|
| pytabify-3.0.0.tar.gz | 12.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytabify-3.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.2 kB
Release files / pytabify-3.0.0.tar.gz
| Download URL | pytabify-3.0.0.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b94d66e863a8f2b36a1123bd84140601c5ce624f196fb85a2bec819e0546cfa
|
|
BLAKE2b-256 checksum How to use checksums |
605173f528e54bd49f97ffb0907fc63859dc166e79b908248ee0c31309a0a34c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 24, 2026.
Transparency logRelease files / pytabify-3.0.0-py3-none-any.whl
| Download URL | pytabify-3.0.0-py3-none-any.whl |
|---|---|
| Size | 22.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0ccd708cce362e143fa48013a94e9e0dd5900d27b454d3cb64fc11e58f5ee921
|
|
BLAKE2b-256 checksum How to use checksums |
7fad091161e153dfd19193439499d2fd86001262263b7d7faaacca4e6d38e4dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 24, 2026.
Transparency log