Tables
provide.foundation.formatting.tables
¶
TODO: Add module docstring.
Functions¶
format_table
¶
format_table(
headers: list[str],
rows: list[list[Any]],
alignment: list[str] | None = None,
) -> str
Format data as ASCII table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
headers
|
list[str]
|
Column headers |
required |
rows
|
list[list[Any]]
|
Data rows |
required |
alignment
|
list[str] | None
|
Column alignments ('l', 'r', 'c') |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted table string |
Examples:
>>> headers = ['Name', 'Age']
>>> rows = [['Alice', 30], ['Bob', 25]]
>>> print(format_table(headers, rows))
Name | Age
------|----
Alice | 30
Bob | 25