Warning: This document is for the development version of terminaltables. The latest version is v3.1.0.

AsciiTable

AsciiTable is the simplest table. It uses +, |, and - characters to build the borders.

_images/asciitable.png

API

class terminaltables.AsciiTable(table_data, title=None)

Draw a table using regular ASCII characters, such as +, |, and -.

Variables:
  • table_data (iter) – List (empty or list of lists of strings) representing the table.
  • title (str) – Optional title to show within the top border of the table.
  • inner_column_border (bool) – Separates columns.
  • inner_footing_row_border (bool) – Show a border before the last row.
  • inner_heading_row_border (bool) – Show a border after the first row.
  • inner_row_border (bool) – Show a border in between every row.
  • outer_border (bool) – Show the top, left, right, and bottom border.
  • justify_columns (dict) – Horizontal justification. Keys are column indexes (int). Values are right/left/center.
  • padding_left (int) – Number of spaces to pad on the left side of every cell.
  • padding_right (int) – Number of spaces to pad on the right side of every cell.
column_max_width(column_number)

Return the maximum width of a column based on the current terminal width.

Parameters:column_number (int) – The column number to query.
Returns:The max width of the column.
Return type:int
column_widths

Return a list of integers representing the widths of each table column without padding.

ok

Return True if the table fits within the terminal width, False if the table breaks.

table

Return a large string of the entire table ready to be printed to the terminal.

table_width

Return the width of the table including padding and borders.