pretty-tables


Namepretty-tables JSON
Version 3.1.0 PyPI version JSON
download
home_pagehttp://github.com/justintime50/pretty-tables
SummaryCreate pretty tables from headers and rows, perfect for console output.
upload_time2023-08-18 04:53:55
maintainer
docs_urlNone
authorJustintime50
requires_python>=3.8, <4
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">

# Pretty Tables

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

[![Build Status](https://github.com/Justintime50/pretty-tables/workflows/build/badge.svg)](https://github.com/Justintime50/pretty-tables/actions)
[![Coverage Status](https://coveralls.io/repos/github/Justintime50/pretty-tables/badge.svg?branch=main)](https://coveralls.io/github/Justintime50/pretty-tables?branch=main)
[![PyPi](https://img.shields.io/pypi/v/pretty-tables)](https://pypi.org/project/pretty-tables/)
[![Licence](https://img.shields.io/github/license/justintime50/pretty-tables)](LICENSE)

<img src="https://raw.githubusercontent.com/justintime50/assets/main/src/pretty-tables/showcase.png" alt="Showcase">

</div>

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

```bash
# 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`:

```python
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

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

## Attribution

- [Stack Overflow question on formatting tables for console](https://stackoverflow.com/a/8356620/865091)

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/justintime50/pretty-tables",
    "name": "pretty-tables",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8, <4",
    "maintainer_email": "",
    "keywords": "",
    "author": "Justintime50",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/21/98/68fd23374ea746b80fe06f6eaad805c9d21f003416ae2696441bf5996bcb/pretty-tables-3.1.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n\n# Pretty Tables\n\nCreate pretty tables from headers and rows, perfect for console output.\n\n[![Build Status](https://github.com/Justintime50/pretty-tables/workflows/build/badge.svg)](https://github.com/Justintime50/pretty-tables/actions)\n[![Coverage Status](https://coveralls.io/repos/github/Justintime50/pretty-tables/badge.svg?branch=main)](https://coveralls.io/github/Justintime50/pretty-tables?branch=main)\n[![PyPi](https://img.shields.io/pypi/v/pretty-tables)](https://pypi.org/project/pretty-tables/)\n[![Licence](https://img.shields.io/github/license/justintime50/pretty-tables)](LICENSE)\n\n<img src=\"https://raw.githubusercontent.com/justintime50/assets/main/src/pretty-tables/showcase.png\" alt=\"Showcase\">\n\n</div>\n\nPretty 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.\n\n## Install\n\n```bash\n# Install package\npip3 install pretty-tables\n\n# Install locally\njust install\n```\n\n## Usage\n\nPretty 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.\n\nPretty 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`:\n\n```python\nimport pretty_tables\n\nheaders = ['ID', 'Name', 'Occupation', 'Employed']\nrows = [\n    [1, 'Justin', 'Software Engineer', True],\n    [2, 'Misty', 'Receptionist', False],\n    [3, 'John', None, False],\n]\n\n# Add optional custom colors to each column\ncolors = [\n    pretty_tables.Colors.red,\n    pretty_tables.Colors.green,\n    pretty_tables.Colors.blue,\n    pretty_tables.Colors.purple,\n]\n\n# Generate the pretty table output\ntable = pretty_tables.create(\n    headers=headers,\n    rows=rows,\n    empty_cell_placeholder='No data',  # Optional: override the default `None` with a custom string\n    colors=colors,  # Optional: mutually exclusive with `truthy`\n    # truthy=3,  # Optional: integer of the column you want to check for truthy values on, mutually exclusive with `colors`\n)\n\nprint(table)\n```\n\n### Colors\n\nYou 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.\n\n- black\n- blue\n- cyan\n- green\n- purple\n- red\n- white\n- yellow\n- bold\n- reset (resets all text formatting)\n- underline\n- none (acts like reset, used instead of passing `None` as a color)\n\n## Development\n\n```bash\n# Get a comprehensive list of development tools\njust --list\n```\n\n## Attribution\n\n- [Stack Overflow question on formatting tables for console](https://stackoverflow.com/a/8356620/865091)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Create pretty tables from headers and rows, perfect for console output.",
    "version": "3.1.0",
    "project_urls": {
        "Homepage": "http://github.com/justintime50/pretty-tables"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7a32fbec49bdd9be339103843529b9c1c78a4467ad0616634f56e7e06a239ec6",
                "md5": "6dd2aac6e54041548b20c2ce485f2d00",
                "sha256": "45a714f39e669ff554f32e4a87417dd14ca33481e40ea02be613679241768741"
            },
            "downloads": -1,
            "filename": "pretty_tables-3.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6dd2aac6e54041548b20c2ce485f2d00",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8, <4",
            "size": 6494,
            "upload_time": "2023-08-18T04:53:54",
            "upload_time_iso_8601": "2023-08-18T04:53:54.089431Z",
            "url": "https://files.pythonhosted.org/packages/7a/32/fbec49bdd9be339103843529b9c1c78a4467ad0616634f56e7e06a239ec6/pretty_tables-3.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "219868fd23374ea746b80fe06f6eaad805c9d21f003416ae2696441bf5996bcb",
                "md5": "8a488fad59ffcc5e77a1aac9cd41eb74",
                "sha256": "c95ee4f78b4fce96718bdb086d8f0c6d5203955b85102e952ae611ad601c4f7a"
            },
            "downloads": -1,
            "filename": "pretty-tables-3.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "8a488fad59ffcc5e77a1aac9cd41eb74",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8, <4",
            "size": 7250,
            "upload_time": "2023-08-18T04:53:55",
            "upload_time_iso_8601": "2023-08-18T04:53:55.579952Z",
            "url": "https://files.pythonhosted.org/packages/21/98/68fd23374ea746b80fe06f6eaad805c9d21f003416ae2696441bf5996bcb/pretty-tables-3.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-18 04:53:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "justintime50",
    "github_project": "pretty-tables",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pretty-tables"
}
        
Elapsed time: 0.30201s