Texttable

1.7.0 · active · verified Sun Mar 29

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.

Warnings

Install

Imports

Quickstart

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.

from texttable import Texttable

table = Texttable()

# Set column alignments (left, right, center)
table.set_cols_align(["l", "r", "c"])

# Set column data types (text, float, integer)
table.set_cols_dtype(["t", "f", "i"])

# Add a header row
table.header(["Name", "Score", "Rank"])

# Add rows of data
table.add_row(["Alice", 95.5, 1])
table.add_row(["Bob", 88.0, 2])
table.add_row(["Charlie", 72.3, 3])

# Draw and print the table
print(table.draw())

view raw JSON →