{"id":20462002,"url":"https://github.com/denvercoder1/table2ascii","last_synced_at":"2025-04-04T18:04:48.891Z","repository":{"id":40537063,"uuid":"361999197","full_name":"DenverCoder1/table2ascii","owner":"DenverCoder1","description":"An intuitive and type-safe Python library for converting lists to fancy ASCII tables for displaying in the terminal or code-blocks","archived":false,"fork":false,"pushed_at":"2025-03-24T15:03:22.000Z","size":2974,"stargazers_count":68,"open_issues_count":2,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T17:08:12.835Z","etag":null,"topics":["ascii","discord","discord-py","formatter","graphics","hacktoberfest","markdown","pretty-print","python","terminal","terminal-graphics","unicode","utilities","utils"],"latest_commit_sha":null,"homepage":"https://table2ascii.rtfd.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DenverCoder1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["DenverCoder1"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-04-27T06:05:13.000Z","updated_at":"2025-03-28T16:34:56.000Z","dependencies_parsed_at":"2024-03-18T23:24:28.659Z","dependency_job_id":"419ae721-7985-4b44-a9df-a3c90cce9696","html_url":"https://github.com/DenverCoder1/table2ascii","commit_stats":{"total_commits":178,"total_committers":8,"mean_commits":22.25,"dds":0.1123595505617978,"last_synced_commit":"9adec7a24e6c0ea824c4e0b96d92ca75c33e4ae7"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DenverCoder1%2Ftable2ascii","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DenverCoder1%2Ftable2ascii/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DenverCoder1%2Ftable2ascii/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DenverCoder1%2Ftable2ascii/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DenverCoder1","download_url":"https://codeload.github.com/DenverCoder1/table2ascii/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226213,"owners_count":20904465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ascii","discord","discord-py","formatter","graphics","hacktoberfest","markdown","pretty-print","python","terminal","terminal-graphics","unicode","utilities","utils"],"created_at":"2024-11-15T12:29:27.762Z","updated_at":"2025-04-04T18:04:48.861Z","avatar_url":"https://github.com/DenverCoder1.png","language":"Python","readme":"# table2ascii\n\n[![build](https://img.shields.io/github/actions/workflow/status/DenverCoder1/table2ascii/python-test.yml?branch=main)](https://github.com/DenverCoder1/table2ascii/actions/workflows/python-app.yml)\n[![version](https://img.shields.io/pypi/v/table2ascii)](https://pypi.org/project/table2ascii/)\n[![downloads](https://static.pepy.tech/personalized-badge/table2ascii?period=total\u0026left_color=grey\u0026right_color=blue\u0026left_text=downloads)](https://pepy.tech/project/table2ascii)\n[![license](https://img.shields.io/pypi/l/table2ascii)](https://github.com/DenverCoder1/table2ascii/blob/main/LICENSE)\n[![discord](https://img.shields.io/discord/819650821314052106?color=5865F2\u0026logo=discord\u0026logoColor=white \"Dev Pro Tips Discussion \u0026 Support Server\")](https://discord.gg/fPrdqh3Zfu)\n\nAn intuitive and type-safe library for converting 2D Python lists to fancy ASCII/Unicode tables\n\nDocumentation and examples are available at [table2ascii.rtfd.io](https://table2ascii.readthedocs.io/)\n\n## 📥 Installation\n\n`pip install -U table2ascii`\n\n**Requirements:** `Python 3.7+`\n\n## 🧑‍💻 Usage\n\n### 🚀 Convert lists to ASCII tables\n\n```py\nfrom table2ascii import table2ascii\n\noutput = table2ascii(\n    header=[\"#\", \"G\", \"H\", \"R\", \"S\"],\n    body=[[\"1\", \"30\", \"40\", \"35\", \"30\"], [\"2\", \"30\", \"40\", \"35\", \"30\"]],\n    footer=[\"SUM\", \"130\", \"140\", \"135\", \"130\"],\n)\n\nprint(output)\n\n\"\"\"\n╔═════════════════════════════╗\n║  #     G     H     R     S  ║\n╟─────────────────────────────╢\n║  1    30    40    35    30  ║\n║  2    30    40    35    30  ║\n╟─────────────────────────────╢\n║ SUM   130   140   135   130 ║\n╚═════════════════════════════╝\n\"\"\"\n```\n\n### 🏆 Set first or last column headings\n\n```py\nfrom table2ascii import table2ascii\n\noutput = table2ascii(\n    body=[[\"Assignment\", \"30\", \"40\", \"35\", \"30\"], [\"Bonus\", \"10\", \"20\", \"5\", \"10\"]],\n    first_col_heading=True,\n)\n\nprint(output)\n\n\"\"\"\n╔════════════╦═══════════════════╗\n║ Assignment ║ 30   40   35   30 ║\n║    Bonus   ║ 10   20    5   10 ║\n╚════════════╩═══════════════════╝\n\"\"\"\n```\n\n### 📰 Set column widths and alignments\n\n```py\nfrom table2ascii import table2ascii, Alignment\n\noutput = table2ascii(\n    header=[\"Product\", \"Category\", \"Price\", \"Rating\"],\n    body=[\n        [\"Milk\", \"Dairy\", \"$2.99\", \"6.283\"],\n        [\"Cheese\", \"Dairy\", \"$10.99\", \"8.2\"],\n        [\"Apples\", \"Produce\", \"$0.99\", \"10.00\"],\n    ],\n    column_widths=[12, 12, 12, 12],\n    alignments=[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT, Alignment.DECIMAL],\n)\n\nprint(output)\n\n\"\"\"\n╔═══════════════════════════════════════════════════╗\n║ Product       Category         Price     Rating   ║\n╟───────────────────────────────────────────────────╢\n║ Milk           Dairy           $2.99      6.283   ║\n║ Cheese         Dairy          $10.99      8.2     ║\n║ Apples        Produce          $0.99     10.00    ║\n╚═══════════════════════════════════════════════════╝\n\"\"\"\n```\n\n### 🎨 Use a preset style\n\nSee a list of 30+ preset styles [here](https://table2ascii.readthedocs.io/en/latest/styles.html).\n\n```py\nfrom table2ascii import table2ascii, Alignment, PresetStyle\n\noutput = table2ascii(\n    header=[\"First\", \"Second\", \"Third\", \"Fourth\"],\n    body=[[\"10\", \"30\", \"40\", \"35\"], [\"20\", \"10\", \"20\", \"5\"]],\n    column_widths=[10, 10, 10, 10],\n    style=PresetStyle.ascii_box\n)\n\nprint(output)\n\n\"\"\"\n+----------+----------+----------+----------+\n|  First   |  Second  |  Third   |  Fourth  |\n+----------+----------+----------+----------+\n|    10    |    30    |    40    |    35    |\n+----------+----------+----------+----------+\n|    20    |    10    |    20    |    5     |\n+----------+----------+----------+----------+\n\"\"\"\n\noutput = table2ascii(\n    header=[\"First\", \"Second\", \"Third\", \"Fourth\"],\n    body=[[\"10\", \"30\", \"40\", \"35\"], [\"20\", \"10\", \"20\", \"5\"]],\n    style=PresetStyle.plain,\n    cell_padding=0,\n    alignments=Alignment.LEFT,\n)\n\nprint(output)\n\n\"\"\"\nFirst Second Third Fourth\n10    30     40    35\n20    10     20    5\n\"\"\"\n```\n\n### 🎲 Define a custom style\n\nCheck [`TableStyle`](https://github.com/DenverCoder1/table2ascii/blob/main/table2ascii/table_style.py) for more info and [`PresetStyle`](https://github.com/DenverCoder1/table2ascii/blob/main/table2ascii/preset_style.py) for examples.\n\n```py\nfrom table2ascii import table2ascii, TableStyle\n\nmy_style = TableStyle.from_string(\"*-..*||:+-+:+     *''*\")\n\noutput = table2ascii(\n    header=[\"First\", \"Second\", \"Third\"],\n    body=[[\"10\", \"30\", \"40\"], [\"20\", \"10\", \"20\"], [\"30\", \"20\", \"30\"]],\n    style=my_style\n)\n\nprint(output)\n\n\"\"\"\n*-------.--------.-------*\n| First : Second : Third |\n+-------:--------:-------+\n|  10   :   30   :  40   |\n|  20   :   10   :  20   |\n|  30   :   20   :  30   |\n*-------'--------'-------*\n\"\"\"\n```\n\n### 🪄 Merge adjacent cells\n\n```py\nfrom table2ascii import table2ascii, Merge, PresetStyle\n\noutput = table2ascii(\n    header=[\"#\", \"G\", \"Merge\", Merge.LEFT, \"S\"],\n    body=[\n        [1, 5, 6, 200, Merge.LEFT],\n        [2, \"E\", \"Long cell\", Merge.LEFT, Merge.LEFT],\n        [\"Bonus\", Merge.LEFT, Merge.LEFT, \"F\", \"G\"],\n    ],\n    footer=[\"SUM\", \"100\", \"200\", Merge.LEFT, \"300\"],\n    style=PresetStyle.double_thin_box,\n    first_col_heading=True,\n)\n\nprint(output)\n\n\"\"\"\n╔═════╦═════╤═══════╤═════╗\n║  #  ║  G  │ Merge │  S  ║\n╠═════╬═════╪═══╤═══╧═════╣\n║  1  ║  5  │ 6 │   200   ║\n╟─────╫─────┼───┴─────────╢\n║  2  ║  E  │  Long cell  ║\n╟─────╨─────┴───┬───┬─────╢\n║     Bonus     │ F │  G  ║\n╠═════╦═════╤═══╧═══╪═════╣\n║ SUM ║ 100 │  200  │ 300 ║\n╚═════╩═════╧═══════╧═════╝\n\"\"\"\n```\n\n## ⚙️ Options\n\nAll parameters are optional. At least one of `header`, `body`, and `footer` must be provided.\n\nRefer to the [documentation](https://table2ascii.readthedocs.io/en/stable/api.html#table2ascii) for more information.\n\n|       Option        |                                 Supported Types                                 |                                             Description                                              |\n| :-----------------: | :-----------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------: |\n|      `header`       |              `Sequence[SupportsStr]`, `None`\u003cbr/\u003e(Default: `None`)              |           First table row seperated by header row separator. Values should support `str()`           |\n|       `body`        |         `Sequence[Sequence[SupportsStr]]`, `None`\u003cbr/\u003e(Default: `None`)         |           2D List of rows for the main section of the table. Values should support `str()`           |\n|      `footer`       |              `Sequence[SupportsStr]`, `None`\u003cbr/\u003e(Default: `None`)              |           Last table row seperated by header row separator. Values should support `str()`            |\n|   `column_widths`   |       `Sequence[Optional[int]]`, `None`\u003cbr/\u003e(Default: `None` / automatic)       |                         List of column widths in characters for each column                          |\n|    `alignments`     | `Sequence[Alignment]`, `Alignment`, `None`\u003cbr/\u003e(Default: `None` / all centered) | Column alignments\u003cbr/\u003e(ex. `[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT, Alignment.DECIMAL]`) |\n| `number_alignments` |        `Sequence[Alignment]`, `Alignment`, `None`\u003cbr/\u003e(Default: `None`)         |          Column alignments for numeric values. `alignments` will be used if not specified.           |\n|       `style`       |                `TableStyle`\u003cbr/\u003e(Default: `double_thin_compact`)                |                                  Table style to use for the table\\*                                  |\n| `first_col_heading` |                          `bool`\u003cbr/\u003e(Default: `False`)                          |                   Whether to add a heading column separator after the first column                   |\n| `last_col_heading`  |                          `bool`\u003cbr/\u003e(Default: `False`)                          |                   Whether to add a heading column separator before the last column                   |\n|   `cell_padding`    |                            `int`\u003cbr/\u003e(Default: `1`)                             |           The minimum number of spaces to add between the cell content and the cell border           |\n|    `use_wcwidth`    |                          `bool`\u003cbr/\u003e(Default: `True`)                           |             Whether to use [wcwidth][wcwidth] instead of `len()` to calculate cell width             |\n\n[wcwidth]: https://pypi.org/project/wcwidth/\n\n\\*See a list of all preset styles [here](https://table2ascii.readthedocs.io/en/latest/styles.html).\n\nSee the [API Reference](https://table2ascii.readthedocs.io/en/latest/api.html) for more info.\n\n## 👨‍🎨 Use cases\n\n### 🗨️ Discord messages and embeds\n\n-   Display tables nicely inside markdown code blocks on Discord\n-   Useful for making Discord bots with [Discord.py](https://github.com/Rapptz/discord.py)\n\n![image](https://user-images.githubusercontent.com/20955511/116203248-2973c600-a744-11eb-97d8-4b75ed2845c9.png)\n\n### 💻 Terminal outputs\n\n-   Tables display nicely whenever monospace fonts are fully supported\n-   Tables make terminal outputs look more professional\n\n![image](https://user-images.githubusercontent.com/20955511/207134452-a1eb1b9f-e63b-459b-8feb-fc6c234e902e.png)\n\n## 🤗 Contributing\n\nContributions are welcome!\n\nSee [CONTRIBUTING.md](https://github.com/DenverCoder1/table2ascii/blob/main/CONTRIBUTING.md) for more details on how to get involved.\n","funding_links":["https://github.com/sponsors/DenverCoder1"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenvercoder1%2Ftable2ascii","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenvercoder1%2Ftable2ascii","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenvercoder1%2Ftable2ascii/lists"}