DataTableCreator¶
Public facade for creating tables from files or records.
Operations¶
| Method | Input | Result |
|---|---|---|
from_file(path, **kwargs) |
CSV, JSON or XLSX | Native DataTable |
from_records(records) |
List of dictionaries | Native DataTable |
from_file¶
path selects the input file; its extension selects the reader. sheet_name is required for XLSX. encoding defaults to utf-8 and applies to CSV/JSON, not XLSX.
Valid combinations¶
Specific XLSX sheet
Unsupported extensions raise infrastructure errors. Common mistakes include missing sheet_name, unsupported paths, expecting encoding to affect XLSX and assuming CSV reads native types.
from_records¶
Create a table from memory
datatable = DataTableCreator.from_records(
[
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 25},
]
)
Records must be dictionaries sharing the same tabular schema. Column order follows the first valid record. Names are normalized to strings and must be unique and non-empty.
Usage examples¶
Good practices¶
- Use from_records when data is already in memory or for file-independent fixtures.
- Use from_file when your source is a file.
- Keep input schemas consistent; add new columns afterwards through table updates rather than irregular input rows.
- Prefer JSON, XLSX or from_records for typed data.