DataTableSaver¶
Public facade for saving a native DataTable in supported formats.
Operations¶
| Method | Output | Note |
|---|---|---|
into_csv(datatable, path, encoding="utf-8") |
CSV | Portable interoperability |
into_json(datatable, path, encoding="utf-8") |
JSON | Supported simple types |
into_xlsx(datatable, path, encoding="utf-8") |
XLSX | Spreadsheet output |
datatable is the native table, path selects the output file, and encoding applies to CSV/JSON.
Save one table in multiple formats¶
Save one table
from pytabify import DataTableCreator, DataTableSaver
datatable = DataTableCreator.from_records(
[
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 25},
]
)
DataTableSaver.into_csv(datatable, "people.csv")
DataTableSaver.into_json(datatable, "people.json")
DataTableSaver.into_xlsx(datatable, "people.xlsx")
Parameters¶
| Parameter | Required | Meaning |
|---|---|---|
| datatable | Yes | Native DataTable |
| path | Yes | Output path |
| encoding | No | CSV/JSON encoding |
Usage variants¶
Convert JSON to XLSX
JSON and XLSX represent supported int, bool and None values better than CSV. Invalid paths or adapter failures raise write exceptions; check permissions, path and extension.
Common mistakes¶
- Unsupported path extension.
- Expecting encoding to change XLSX writing.
- Passing an object other than native DataTable.
- Assuming CSV preserves types like JSON/XLSX.
Good practices¶
Match extension and intended format. Choose CSV for portability, JSON for typed round-trips, and into_xlsx when Excel is the destination.
[{"name": "English", "lang": "en", "link": "/pytabify/reference/saver/", "fragments": {"datatablesaver": "datatablesaver", "operations": "operations", "save-one-table-in-multiple-formats": "save-one-table-in-multiple-formats", "parameters": "parameters", "usage-variants": "usage-variants", "common-mistakes": "common-mistakes", "good-practices": "good-practices"}, "current": true}, {"name": "Espa\u00f1ol", "lang": "es", "link": "/pytabify/es/reference/saver/", "fragments": {}, "current": false}]