Skip to main content

Render data as clean ASCII/Unicode tables in the terminal with zero configuration

Project description

philiprehberger-text-table

Render data as clean ASCII/Unicode tables in the terminal with zero configuration.

Install

pip install philiprehberger-text-table

Usage

from philiprehberger_text_table import table

headers = ["Name", "Age", "City"]
rows = [
    ["Alice", 30, "New York"],
    ["Bob", 25, "London"],
    ["Charlie", 35, "Tokyo"],
]

print(table(headers, rows))

Output:

┌─────────┬─────┬──────────┐
│ Name    │ Age │ City     │
├─────────┼─────┼──────────┤
│ Alice   │  30 │ New York │
│ Bob     │  25 │ London   │
│ Charlie │  35 │ Tokyo    │
└─────────┴─────┴──────────┘

From dictionaries

from philiprehberger_text_table import from_dicts

data = [
    {"name": "Alice", "score": 95},
    {"name": "Bob", "score": 87},
]

print(from_dicts(data))

From CSV

from philiprehberger_text_table import from_csv

print(from_csv("data.csv"))

Styles

# ASCII style
print(table(headers, rows, style="ascii"))

# Markdown style
print(table(headers, rows, style="markdown"))

# Minimal style (no borders)
print(table(headers, rows, style="minimal"))

# Compact style (no outer borders)
print(table(headers, rows, style="compact"))

Truncation

print(table(headers, rows, max_width=10))

API

Function Description
table(headers, rows, *, style="unicode", max_width=None) Render a table from headers and row data
from_dicts(data, *, style="unicode", max_width=None) Render a table from a list of dictionaries
from_csv(path, *, style="unicode", max_width=None) Read a CSV file and render as a table

Styles: "unicode", "ascii", "markdown", "minimal", "compact"

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

philiprehberger_text_table-0.1.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_text_table-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_text_table-0.1.1.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_text_table-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4f764255727adf66b370a7abbe95969827c26e5cbe456b2d4e6fd80525bb9bb1
MD5 85cb1a4893cae52dc3c5a4c36ae340cf
BLAKE2b-256 61b2b5cbf9f68f853c341c15d3def114de26a67405683d08eec066a4c729a0f8

See more details on using hashes here.

File details

Details for the file philiprehberger_text_table-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_text_table-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0b8eee63f135cfdea3a450bb059d31d4fb97a0e2c54225d0a960622b9834ed3f
MD5 0a70e7c9fb11cd9e5269a0f93171b4d2
BLAKE2b-256 cdc3f1bccd46c6371f1d2ab45c80f8d88721187cf75d4713b5734aba6a5bd37b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page