terminaltables

3.1.10 · abandoned · verified Thu Apr 09

terminaltables is a Python library designed to easily draw tables in terminal/console applications from a nested list of strings. It supports multi-line rows and various table styles like ASCII, single-line, double-line, and GitHub Flavored Markdown. The current version is 3.1.10, but the project is no longer actively maintained.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a basic ASCII table using `AsciiTable` by providing a list of lists. It also shows how to set a table title. Other table types like `SingleTable` and `DoubleTable` are used similarly.

from terminaltables import AsciiTable

table_data = [
    ['Heading1', 'Heading2', 'Heading3'],
    ['Row1 Col1', 'Row1 Col2', 'Row1 Col3'],
    ['Row2 Col1', 'Row2 Col2 with a long text that wraps', 'Row2 Col3'],
    ['Row3 Col1', 'Row3 Col2', 'Row3 Col3']
]

table = AsciiTable(table_data)
# You can also set a title
table.title = 'My Awesome Table'

# Adjust column alignment (l=left, c=center, r=right)
# table.justify_columns = {'Heading1': 'left', 'Heading2': 'center'}

print(table.table)

view raw JSON →