Texttable is a Python module to create simple ASCII tables. It provides an easy-to-use API for formatting data into human-readable text tables, supporting various alignments, data types, and decorative options. The current version is 1.7.0, and it is actively maintained with regular updates.
pip install texttableVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a basic ASCII table, set column alignments and data types, add a header, and populate it with data before printing.
Call `table.set_cols_dtype(['t', 'f', 'i', 'a'])` before adding rows to define how each column's data should be handled (text, float, integer, auto).
Initialize `Texttable` with `table = Texttable(max_width=0)` for a dynamically sized table, or carefully manage `max_width` if wrapping is desired.
Upgrade to version 1.6.6 or later, which includes a fix for this regression.
Upgrade to version 1.7.0 or newer to leverage the enhanced boolean formatting capabilities.
Ensure each list passed to `add_row()` contains the same number of elements as the table's total column count, which is often determined by the first row added or methods like `set_cols_align`.
Pass a list or tuple of type codes to `set_cols_dtype`, even if defining the type for only one column, e.g., `table.set_cols_dtype(['t', 'f'])`.
Use one of the supported type codes: 't' (text), 'f' (float), 'e' (scientific), 'i' (integer), 'a' (auto), 'd' (date).
Correct the capitalization in the import statement: `from texttable import Texttable`.