tablur


Nametablur JSON
Version 1.2.2 PyPI version JSON
download
home_pagehttps://github.com/durocodes/tablur
SummaryA simple library for creating formatted tables with box-drawing characters
upload_time2025-09-07 00:47:10
maintainerNone
docs_urlNone
authorDuro
requires_python>=3.10
licenseMIT
keywords table formatting ascii box-drawing terminal callable
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tablur

<div align="center">
  <img src="https://raw.githubusercontent.com/durocodes/tablur/main/logo.png" width="400" />
</div>

a simple python library for creating beautifully formatted tables with box-drawing characters.

## features

- **simple interface**: use `tablur()` and `simple()` functions
- create tables with box-drawing characters (╭─╮│├┼┤┴╰)
- support for optional headers and footers
- automatic column width calculation
- three input formats: column-based, dictionary, and row-based
- returns formatted strings (no automatic printing)
- lightweight and blazingly fast

## installation

```bash
pip install tablur
```

## usage

### column-based format (default)

```python
from tablur import tablur

# data is defined as a list of tuples where each tuple contains `(column_name, column_data)`
data = [
    ("Name", ["Alice", "Bob", "Charlie"]),
    ("Age", [25, 30, 35]),
    ("City", ["New York", "London", "Tokyo"]),
    ("Salary", [50000, 60000, 70000]),
]

# using the `tablur` function
table = tablur(
    data,
    header="Employee Directory",
    footer="Total: 3 employees",
    chars=["╭", "╮", "╰", "╯", "├", "┤", "┬", "┴", "┼", "─", "│"] # this is the default, make sure you use this format
)
print(table)
```

output:

```
╭───────────────────────────────────╮
│        Employee Directory         │
├─────────┬─────┬──────────┬────────┤
│ Name    │ Age │ City     │ Salary │
├─────────┼─────┼──────────┼────────┤
│ Alice   │ 25  │ New York │ 50000  │
│ Bob     │ 30  │ London   │ 60000  │
│ Charlie │ 35  │ Tokyo    │ 70000  │
├─────────┴─────┴──────────┴────────┤
│        Total: 3 employees         │
╰───────────────────────────────────╯
```

### dictionary format

```python
from tablur import tablur

# data can also be a dictionary where keys are column names and values are lists of data
data = {
    "Name": ["Alice", "Bob", "Charlie"],
    "Age": [25, 30, 35],
    "City": ["New York", "London", "Tokyo"],
    "Salary": [50000, 60000, 70000],
}

# using the `tablur` function with dictionary
table = tablur(
    data,
    header="Employee Directory",
    footer="Total: 3 employees"
)
print(table)
```

output:

```
╭───────────────────────────────────╮
│        Employee Directory         │
├─────────┬─────┬──────────┬────────┤
│ Name    │ Age │ City     │ Salary │
├─────────┼─────┼──────────┼────────┤
│ Alice   │ 25  │ New York │ 50000  │
│ Bob     │ 30  │ London   │ 60000  │
│ Charlie │ 35  │ Tokyo    │ 70000  │
├─────────┴─────┴──────────┴────────┤
│        Total: 3 employees         │
╰───────────────────────────────────╯
```

### row-based format

```python
from tablur import simple

# data is just a list of rows, where each row is a list of values
data = [
    ["Alice", 25, "New York"],
    ["Bob", 30, "London"],
    ["Charlie", 35, "Tokyo"]
]

# with simple, you can define the headers explicitly or not (they default to indices)
table = simple(data, headers=["Name", "Age", "City"])
print(table)
```

> [!NOTE]
> The `simple()` function also supports dictionary format, just like `tablur()`.

output:

```
╭─────────┬─────┬──────────╮
│ Name    │ Age │ City     │
├─────────┼─────┼──────────┤
│ Alice   │ 25  │ New York │
│ Bob     │ 30  │ London   │
│ Charlie │ 35  │ Tokyo    │
╰─────────┴─────┴──────────╯
```

## license

mit, you can do whatever you want with the code :D

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/durocodes/tablur",
    "name": "tablur",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "table, formatting, ascii, box-drawing, terminal, callable",
    "author": "Duro",
    "author_email": "Duro <davidwright13503@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/dc/a9/15cd031b8e836a6d213528bd7a2289f6e034be1354e44743b9a0c026bce5/tablur-1.2.2.tar.gz",
    "platform": null,
    "description": "# tablur\n\n<div align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/durocodes/tablur/main/logo.png\" width=\"400\" />\n</div>\n\na simple python library for creating beautifully formatted tables with box-drawing characters.\n\n## features\n\n- **simple interface**: use `tablur()` and `simple()` functions\n- create tables with box-drawing characters (\u256d\u2500\u256e\u2502\u251c\u253c\u2524\u2534\u2570)\n- support for optional headers and footers\n- automatic column width calculation\n- three input formats: column-based, dictionary, and row-based\n- returns formatted strings (no automatic printing)\n- lightweight and blazingly fast\n\n## installation\n\n```bash\npip install tablur\n```\n\n## usage\n\n### column-based format (default)\n\n```python\nfrom tablur import tablur\n\n# data is defined as a list of tuples where each tuple contains `(column_name, column_data)`\ndata = [\n    (\"Name\", [\"Alice\", \"Bob\", \"Charlie\"]),\n    (\"Age\", [25, 30, 35]),\n    (\"City\", [\"New York\", \"London\", \"Tokyo\"]),\n    (\"Salary\", [50000, 60000, 70000]),\n]\n\n# using the `tablur` function\ntable = tablur(\n    data,\n    header=\"Employee Directory\",\n    footer=\"Total: 3 employees\",\n    chars=[\"\u256d\", \"\u256e\", \"\u2570\", \"\u256f\", \"\u251c\", \"\u2524\", \"\u252c\", \"\u2534\", \"\u253c\", \"\u2500\", \"\u2502\"] # this is the default, make sure you use this format\n)\nprint(table)\n```\n\noutput:\n\n```\n\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502        Employee Directory         \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 Name    \u2502 Age \u2502 City     \u2502 Salary \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 Alice   \u2502 25  \u2502 New York \u2502 50000  \u2502\n\u2502 Bob     \u2502 30  \u2502 London   \u2502 60000  \u2502\n\u2502 Charlie \u2502 35  \u2502 Tokyo    \u2502 70000  \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502        Total: 3 employees         \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\n### dictionary format\n\n```python\nfrom tablur import tablur\n\n# data can also be a dictionary where keys are column names and values are lists of data\ndata = {\n    \"Name\": [\"Alice\", \"Bob\", \"Charlie\"],\n    \"Age\": [25, 30, 35],\n    \"City\": [\"New York\", \"London\", \"Tokyo\"],\n    \"Salary\": [50000, 60000, 70000],\n}\n\n# using the `tablur` function with dictionary\ntable = tablur(\n    data,\n    header=\"Employee Directory\",\n    footer=\"Total: 3 employees\"\n)\nprint(table)\n```\n\noutput:\n\n```\n\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502        Employee Directory         \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 Name    \u2502 Age \u2502 City     \u2502 Salary \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 Alice   \u2502 25  \u2502 New York \u2502 50000  \u2502\n\u2502 Bob     \u2502 30  \u2502 London   \u2502 60000  \u2502\n\u2502 Charlie \u2502 35  \u2502 Tokyo    \u2502 70000  \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502        Total: 3 employees         \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\n### row-based format\n\n```python\nfrom tablur import simple\n\n# data is just a list of rows, where each row is a list of values\ndata = [\n    [\"Alice\", 25, \"New York\"],\n    [\"Bob\", 30, \"London\"],\n    [\"Charlie\", 35, \"Tokyo\"]\n]\n\n# with simple, you can define the headers explicitly or not (they default to indices)\ntable = simple(data, headers=[\"Name\", \"Age\", \"City\"])\nprint(table)\n```\n\n> [!NOTE]\n> The `simple()` function also supports dictionary format, just like `tablur()`.\n\noutput:\n\n```\n\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 Name    \u2502 Age \u2502 City     \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 Alice   \u2502 25  \u2502 New York \u2502\n\u2502 Bob     \u2502 30  \u2502 London   \u2502\n\u2502 Charlie \u2502 35  \u2502 Tokyo    \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\n## license\n\nmit, you can do whatever you want with the code :D\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A simple library for creating formatted tables with box-drawing characters",
    "version": "1.2.2",
    "project_urls": {
        "Homepage": "https://github.com/durocodes/tablur",
        "Issues": "https://github.com/durocodes/tablur/issues",
        "Repository": "https://github.com/durocodes/tablur"
    },
    "split_keywords": [
        "table",
        " formatting",
        " ascii",
        " box-drawing",
        " terminal",
        " callable"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8cf860488c50a9eef04afeb759621025ae18c3f4815b33c1bd348cc17e7c5e5b",
                "md5": "32f3d2c7e5c6d821f951bf71c9ae4636",
                "sha256": "d3704addef0d0d1e96e2cc390f58f77c1ac20d668a6f19be2108383f68b6099f"
            },
            "downloads": -1,
            "filename": "tablur-1.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "32f3d2c7e5c6d821f951bf71c9ae4636",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 5118,
            "upload_time": "2025-09-07T00:47:09",
            "upload_time_iso_8601": "2025-09-07T00:47:09.648313Z",
            "url": "https://files.pythonhosted.org/packages/8c/f8/60488c50a9eef04afeb759621025ae18c3f4815b33c1bd348cc17e7c5e5b/tablur-1.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dca915cd031b8e836a6d213528bd7a2289f6e034be1354e44743b9a0c026bce5",
                "md5": "472a24d2b0a205a9c8e559e997b238ee",
                "sha256": "9f6562f5e4a133671f6f244eeeca9f30e0e0632cfe2cb617ddba155ac444b991"
            },
            "downloads": -1,
            "filename": "tablur-1.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "472a24d2b0a205a9c8e559e997b238ee",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 5391,
            "upload_time": "2025-09-07T00:47:10",
            "upload_time_iso_8601": "2025-09-07T00:47:10.818600Z",
            "url": "https://files.pythonhosted.org/packages/dc/a9/15cd031b8e836a6d213528bd7a2289f6e034be1354e44743b9a0c026bce5/tablur-1.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-07 00:47:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "durocodes",
    "github_project": "tablur",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tablur"
}
        
Elapsed time: 1.58083s