There are some light and useful python packages for this purpose:

1. tabulate

https://pypi.python.org/pypi/tabulate

from tabulate import tabulate
print(tabulate([['Alice', 24], ['Bob', 19]], headers=['Name', 'Age']))
Name      Age
------  -----
Alice      24
Bob        19

tabulate has many options to specify headers and table format.

print(tabulate(
    [['Alice', 24], ['Bob', 19]],
    headers=['Name', 'Age'],
    tablefmt='orgtbl'))
| Name   |   Age |
|--------+-------|
| Alice  |    24 |
| Bob    |    19 |

2. PrettyTable

https://pypi.python.org/pypi/PrettyTable

from prettytable import PrettyTable
t = PrettyTable(['Name', 'Age'])
t.add_row(['Alice', 24])
t.add_row(['Bob', 19])
print(t)
+-------+-----+
|  Name | Age |
+-------+-----+
| Alice |  24 |
|  Bob  |  19 |
+-------+-----+

PrettyTable has options to read data from csv, html, sql database. Also you are able to select subset of data, sort table and change table styles.

3. texttable

https://pypi.python.org/pypi/texttable

from texttable import Texttable
t = Texttable()
t.add_rows([['Name', 'Age'], ['Alice', 24], ['Bob', 19]])
print(t.draw())
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

4. termtables

https://github.com/nschloe/termtables

import termtables as tt

string = tt.to_string(
    [["Alice", 24], ["Bob", 19]],
    header=["Name", "Age"],
    style=tt.styles.ascii_thin_double,
    # alignment="ll",
    # padding=(0, 1),
)
print(string)
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

Other options

  • terminaltables - Easily draw tables in terminal/console applications from a list of lists of strings. Supports multi-line rows.
  • asciitable can read and write a wide range of ASCII table formats via built-in Extension Reader Classes.
Answer from iman on Stack Overflow
🌐
PyPI
pypi.org › project › tabulate
tabulate · PyPI
Pretty-print tabular data in Python, a library and a command-line utility.
      » pip install tabulate
    
Published   Mar 04, 2026
Version   0.10.0
🌐
DataCamp
datacamp.com › tutorial › python-tabulate
Python Tabulate: A Full Guide | DataCamp
September 5, 2024 - The pandas DataFrame is a common data structure in Python that handles tabular data. Using the tabulate library, you can format the tabular data in different formats according to the required specifications. The following example shows how to display a table using the ‘pipe’ format.
🌐
Python for Network Engineers
pyneng.readthedocs.io › en › latest › book › 12_useful_modules › tabulate.html
tabulate - Python for network engineers
In [25]: print(tabulate(list_of_dict, headers='keys', tablefmt='pipe')) | Interface | IP | Status | Protocol | |:----------------|:----------|:---------|:-----------| | FastEthernet0/0 | 15.0.15.1 | up | up | | FastEthernet0/1 | 10.0.12.1 | up | up | | FastEthernet0/2 | 10.0.13.1 | up | up | | Loopback0 | 10.1.1.1 | up | up | | Loopback100 | 100.0.0.1 | up | up |
🌐
GeeksforGeeks
geeksforgeeks.org › python › introduction-to-python-tabulate-library
Introduction to Python Tabulate Library - GeeksforGeeks
July 23, 2025 - In this article, we will explore the features, installation, and usage of the Python tabulate module and work through an example to demonstrate how it can be applied.
🌐
AskPython
askpython.com › home › python tabulate module: how to easily create tables in python?
Python tabulate module: How to Easily Create Tables in Python? - AskPython
June 8, 2023 - Python tabulate makes creating and formatting tables easy and efficient. Start by importing the module. You can then create a table by storing your data in a nested list and passing it to the tabulate function. To enhance the look of your table, use the tablefmt attribute and set it to grid for a bordered table, or fancy_grid for a more sophisticated border.
🌐
Medium
medium.com › @jainsnehasj6 › mastering-tabulate-in-python-create-beautiful-tables-effortlessly-50f70a75862c
Mastering Tabulate in Python: Create Beautiful Tables Effortlessly | by Sneha Jain | Medium
November 4, 2025 - from tabulate import tabulate headers ... Noah Harari"], ["Python Crash Course", "Eric Matthes"] ] print(tabulate(data, headers=headers, showindex=[YOUR_CHOICE_HERE]))...
🌐
GitHub
github.com › gregbanks › python-tabulate
GitHub - gregbanks/python-tabulate: fork of https://bitbucket.org/astanin/python-tabulate · GitHub
>>> from tabulate import tabulate ...s",3390,641.85]] >>> print tabulate(table) ----- ------ ------------- Sun 696000 1.9891e+09 Earth 6371 5973.6 Moon 1737 73.5 Mars 3390 641.85 ----- ------ ------------- ... Examples in this ...
Starred by 188 users
Forked by 14 users
Languages   Python
Top answer
1 of 16
1041

There are some light and useful python packages for this purpose:

1. tabulate

https://pypi.python.org/pypi/tabulate

from tabulate import tabulate
print(tabulate([['Alice', 24], ['Bob', 19]], headers=['Name', 'Age']))
Name      Age
------  -----
Alice      24
Bob        19

tabulate has many options to specify headers and table format.

print(tabulate(
    [['Alice', 24], ['Bob', 19]],
    headers=['Name', 'Age'],
    tablefmt='orgtbl'))
| Name   |   Age |
|--------+-------|
| Alice  |    24 |
| Bob    |    19 |

2. PrettyTable

https://pypi.python.org/pypi/PrettyTable

from prettytable import PrettyTable
t = PrettyTable(['Name', 'Age'])
t.add_row(['Alice', 24])
t.add_row(['Bob', 19])
print(t)
+-------+-----+
|  Name | Age |
+-------+-----+
| Alice |  24 |
|  Bob  |  19 |
+-------+-----+

PrettyTable has options to read data from csv, html, sql database. Also you are able to select subset of data, sort table and change table styles.

3. texttable

https://pypi.python.org/pypi/texttable

from texttable import Texttable
t = Texttable()
t.add_rows([['Name', 'Age'], ['Alice', 24], ['Bob', 19]])
print(t.draw())
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

4. termtables

https://github.com/nschloe/termtables

import termtables as tt

string = tt.to_string(
    [["Alice", 24], ["Bob", 19]],
    header=["Name", "Age"],
    style=tt.styles.ascii_thin_double,
    # alignment="ll",
    # padding=(0, 1),
)
print(string)
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

Other options

  • terminaltables - Easily draw tables in terminal/console applications from a list of lists of strings. Supports multi-line rows.
  • asciitable can read and write a wide range of ASCII table formats via built-in Extension Reader Classes.
2 of 16
324

Some ad-hoc code:

row_format ="{:>15}" * (len(teams_list) + 1)
print(row_format.format("", *teams_list))
for team, row in zip(teams_list, data):
    print(row_format.format(team, *row))

This relies on str.format() and the Format Specification Mini-Language.

Find elsewhere
🌐
Analytics India Magazine
analyticsindiamag.com › deep-tech › beginners-guide-to-tabulate-python-tool-for-creating-nicely-formatted-tables
Tabulate python Examples to Create Formatted Tables
December 30, 2024 - In this article, we will see what are the different types of table formatting we can perform using Tabulate - A a Python tool
🌐
Analytics Vidhya
analyticsvidhya.com › home › comprehensive guide to python’s tabulate library
Comprehensive Guide to Python's Tabulate Library - Analytics Vidhya
May 29, 2025 - Learn everything about python's Tabulate category, how to use, what are the different features, applications, examples and more.
🌐
GitHub
github.com › thruston › python-tabulate
GitHub - thruston/python-tabulate: A neat-text-table filter · GitHub
So I have re-written the original Perl version of tabulate as a Python module that can be imported, and used to tidy up a list of lists of data for printing directly as part of a script. ... You can use tabulate from the command line, from your editor, or as a Python module.
Author   thruston
🌐
Snyk
snyk.io › advisor › tabulate › functions › tabulate.tabulate
How to use the tabulate.tabulate function in tabulate | Snyk
if row: onear_rows.append(row) onear_rows = sorted(onear_rows, key=lambda row: float(row[1]), reverse=True) onear_str = tabulate(onear_rows, headers=['Name', 'Score', 'STD (dB)', 'Slope'], tablefmt='orgtbl') onear_str = onear_str.replace('+', '|').replace('|-', '|:') inear_rows = [] # oratory1990 and Crinacle in-ear files = list(glob(os.path.join(ROOT_DIR, 'results', 'oratory1990', 'harman_in-ear_2019v2', '*', '*.csv'))) files += list(glob(os.path.join(ROOT_DIR, 'results', 'crinacle', 'harman_in-ear_2019v2', '*', '*.csv'))) for fp in files: row = ranking_row(fp, harman_inear, 'inear') if row:
🌐
Snyk
snyk.io › advisor › tabulate › tabulate code examples
Top 5 tabulate Code Examples | Snyk
rows = [] header = ['Operation', 'Response\nCount', 'RespSize\nBytes', 'MaxObjCnt\nRequest', 'operation\nCount', 'Total execution\ntime (hh:mm:ss)', 'inst/sec', 'runid'] for response_size in response_sizes: for response_count in response_counts: # run_single_test(conn, response_count, response_size, pull_sizes) rows.extend(run_single_test(conn, runid, response_count, response_size, pull_sizes)) print(' Response results for pywbem version %s runid %s execution time %s' % (__version__, runid, format_timedelta(test_timer.elapsed_time()))) table = tabulate(rows, headers=header, tablefmt="simple") print(table) if verbose: rows = [] for stat in STATS_LIST: rows.append(stat) headers = ['Operation', 'Max Object\ncount', 'Op\nCount', 'inst count', 'Operation\nTime'] table = tabulate(rows, headers=headers) print(table) astanin / python-tabulate / test / test_regression.py View on Github
🌐
Packetswitch
packetswitch.co.uk › how-to-create-tables-python-tabulate-module
How to Create Tables with Python Tabulate Module
April 26, 2024 - The headers="keys" argument tells Tabulate to automatically use the keys from our dictionaries ('Name', 'Age', 'City') as headers for the columns. This results in a neatly formatted table where each row corresponds to the information of one person, and columns are clearly labelled for easy reading. Up next, let's see how to make numbers in our tables look neat and tidy. We'll use Python's Tabulate module to line up numbers to the right and show prices with just the right amount of decimal points.
🌐
Towards Data Science
towardsdatascience.com › home › latest › how to easily create tables in python
How to Easily Create Tables in Python | Towards Data Science
January 27, 2025 - print(tabulate(table, headers='firstrow', tablefmt='fancy_grid')) Three Concepts to Become a Better Python Programmer
🌐
Pickl
pickl.ai › home › python programming › how to tabulate data in python?
How to Tabulate Data in Python?- Pickl.AI
September 6, 2024 - Learn about How to Tabulate Data In Python from this blog. Learn about the process of tabulating data in Python in a structured format.
🌐
CloudDefense.ai
clouddefense.ai › code › python › example › tabulate
Top 10 Examples of <!-- -->tabulate<!-- --> code in Python | CloudDefense.AI
def test_ansi_color_bold_and_fgcolor(): "Regression: set ANSI color and bold face together (issue #65)" table = [["1", "2", "3"], ["4", "\x1b[1;31m5\x1b[1;m", "6"], ["7", "8", "9"]] result = tabulate(table, tablefmt="grid") expected = "\n".join( [ "+---+---+---+", "| 1 | 2 | 3 |", "+---+---+---+", "| 4 | \x1b[1;31m5\x1b[1;m | 6 |", "+---+---+---+", "| 7 | 8 | 9 |", "+---+---+---+", ] ) assert_equal(result, expected)
🌐
Medium
medium.com › @HeCanThink › tabulate-your-go-to-solution-for-stylish-tables-in-python-35ede5145e28
Tabulate: Your Go-To Solution for Stylish Tables in Python 👉 | by Manoj Das | Medium
August 19, 2023 - Tabulate: Your Go-To Solution for Stylish Tables in Python 👉 What is Tabulate? How to create formatted tabular data in Python. Tabulate in Python is a popular package that allows you to easily …
🌐
LinkedIn
linkedin.com › pulse › effortless-data-tabulation-python-tabulate-library-360-digitmg
Effortless Data Tabulation in Python with Tabulate Library
September 8, 2023 - Tabulate has gained popularity within the Python community and is actively maintained. This means you can rely on consistent updates, bug fixes, and improvements to the library over time. ... The library comes with comprehensive documentation, including usage examples, explanations of formatting options, and implementation details.
🌐
Copdips
copdips.com › 2018 › 07 › use-python-tabulate-module-to-create-tables.html
Use python tabulate module to create tables - A code to remember
July 28, 2018 - from tabulate import _table_formats, tabulate format_list = list(_table_formats.keys()) # current format list in tabulate version 0.8.3: # ['simple', 'plain', 'grid', 'fancy_grid', 'github', 'pipe', 'orgtbl', 'jira', 'presto', 'psql', 'rst', 'mediawiki', 'moinmoin', 'youtrack', 'html', 'latex', 'latex_raw', 'latex_booktabs', 'tsv', 'textile'] # Each element in the table list is a row in the generated table table = [["spam",42], ["eggs", 451], ["bacon", 0]] headers = ["item", "qty"] for f in format_list: print("\nformat: {}\n".format(f)) print(tabulate(table, headers, tablefmt=f))