Skip to main content

Pretty Tables

Create pretty tables from headers and rows, perfect for console output.

Build Status Coverage Status PyPi Licence

Showcase

Pretty Tables will create uniformly dispersed columns based on the input given and can be scaled to your needs in length of the table or number of columns. The input is automatically validated and allows for custom formatting making generating Pretty Tables a breeze.

Install

# Install package
pip3 install pretty-tables

# Install locally
just install

Usage

Pretty Tables is simple to use. Create a table by calling pretty_tables.create(), pass a list of headers and a 2 dimensional list of rows (each row must match the length of the headers). Pass an optional empty_cell_placeholder string, colors list, or a truthy index to customize your Pretty Table.

Pretty Tables will automatically validate the input and convert each item to a string before returning successfully; however, you can pass Pretty Tables any data type within the header or row lists. In the following example, we are using integers, booleans, None, and strings:

import pretty_tables

headers = ['ID', 'Name', 'Occupation', 'Employed']
rows = [
    [1, 'Justin', 'Software Engineer', True],
    [2, 'Misty', 'Receptionist', False],
    [3, 'John', None, False],
]

# Add optional custom colors to each column
colors = [
    pretty_tables.Colors.red,
    pretty_tables.Colors.green,
    pretty_tables.Colors.blue,
    pretty_tables.Colors.purple,
]

# Generate the pretty table output
table = pretty_tables.create(
    headers=headers,
    rows=rows,
    empty_cell_placeholder='No data',  # Optional: override the default `None` with a custom string
    colors=colors,  # Optional: mutually exclusive with `truthy`
    # truthy=3,  # Optional: integer of the column you want to check for truthy values on, mutually exclusive with `colors`
)

print(table)

Colors

You can also color each column differently by using the colors argument and passing a list of colors from the pretty_tables.Colors class. The input list must match the length of the headers list.

  • black
  • blue
  • cyan
  • green
  • purple
  • red
  • white
  • yellow
  • bold
  • reset (resets all text formatting)
  • underline
  • none (acts like reset, used instead of passing None as a color)

Development

# Get a comprehensive list of development tools
just --list

Attribution

Metadata

Release files for pretty-tables 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pretty-tables 4.0.0
File Size Uploaded Provenance Actions
pretty_tables-4.0.0.tar.gz 7.5 kB Without provenance Details for pretty_tables-4.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pretty-tables 4.0.0
File Interpreter ABI Platform Actions
pretty_tables-4.0.0-py3-none-any.whl Python 3 none any Details for pretty_tables-4.0.0-py3-none-any.whl

Total release size: 14.3 kB

Release files / pretty_tables-4.0.0.tar.gz

Download URL pretty_tables-4.0.0.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0b3432415623176e5f182fc01b2063dce40215f37fdf1aee4052e5a96d40b791
BLAKE2b-256 checksum
How to use checksums
525b98c2838605056aeeb25d841715e17d2b2d5da12b6aa0b0aed4cbaaa5cfed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / pretty_tables-4.0.0-py3-none-any.whl

Download URL pretty_tables-4.0.0-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ea1b930622c43b55f6d44c1a34d1946a6ba75a423724cfb714d9433e6e42fd4
BLAKE2b-256 checksum
How to use checksums
5b3b043ba468a0bc8fa99677ef8f477a7d305c5984d304274bde7bdb4c2e9ccb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for pretty-tables 4.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page