<p align="center">
<a href="https://github.com/nschloe/termtables"><img alt="termtables" src="https://nschloe.github.io/termtables/termtables.svg" width="60%"></a>
<p align="center">The tables have termed.</p>
</p>
[![PyPi Version](https://img.shields.io/pypi/v/termtables.svg?style=flat-square)](https://pypi.org/project/termtables)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/termtables.svg?style=flat-square)](https://pypi.org/pypi/termtables/)
[![GitHub stars](https://img.shields.io/github/stars/nschloe/termtables.svg?logo=github&label=Stars&logoColor=white&style=flat-square)](https://github.com/nschloe/termtables)
[![PyPi downloads](https://img.shields.io/pypi/dm/termtables.svg?style=flat-square)](https://pypistats.org/packages/termtables)
[![gh-actions](https://img.shields.io/github/workflow/status/nschloe/termtables/ci?style=flat-square)](https://github.com/nschloe/termtables/actions?query=workflow%3Aci)
[![codecov](https://img.shields.io/codecov/c/github/nschloe/termtables.svg?style=flat-square)](https://codecov.io/gh/nschloe/termtables)
[![LGTM](https://img.shields.io/lgtm/grade/python/github/nschloe/termtables.svg?style=flat-square)](https://lgtm.com/projects/g/nschloe/termtables)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black)
termtables is a lightweight Python 3 package for pretty-printing tables on the command
line. Install with
```
pip install termtables
```
The code
```python
import termtables as tt
import numpy
numpy.random.seed(0)
data = numpy.random.rand(5, 2)
tt.print(data)
# tt.to_string(data) returns the string
```
produces
![table1](https://nschloe.github.io/termtables/table1.png)
You can control border style, padding, alignment, and various other attributes. For
example,
```python
import termtables as tt
header = ["a", "bb", "ccc"]
data = [
[1, 2, 3], [613.23236243236, 613.23236243236, 613.23236243236]
]
tt.print(
data,
header=header,
style=tt.styles.markdown,
padding=(0, 1),
alignment="lcr"
)
```
produces
<!--pytest-codeblocks:expected-output-->
```
| a | bb | ccc |
|-----------------|-----------------|-----------------|
| 1 | 2 | 3 |
| 613.23236243236 | 613.23236243236 | 613.23236243236 |
```
which is useful for copy-pasting into websites that support Markdown (like GitHub).
See
[`test/test_termtables.py`](https://github.com/nschloe/termtables/blob/master/test/test_termtables.py)
for more examples.
If the styles in `termtables.styles`
```
thin
thin_thick
thin_double
rounded
rounded_thick
rounded_double
thick
thick_thin
double
double_thin
booktabs
ascii_thin
ascii_thin_double
ascii_double
ascii_double_thin
ascii_booktabs
markdown
```
aren't good enough for you, simply provide your own
style as a string of length 11 or 15 (the extra 4 including header-separating
characters). For example
```python
import termtables as tt
header = ["a", "bb", "ccc"]
data = [
[1, 2, 3], [613.23236243236, 613.23236243236, 613.23236243236]
]
tt.print(
data,
header=header,
style="x0123456789abcd"
)
```
produces
<!--pytest-codeblocks:expected-output-->
```
1xxxxxxxxxxxxxxxxx7xxxxxxxxxxxxxxxxx7xxxxxxxxxxxxxxxxx2
0 a 0 bb 0 ccc 0
abbbbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbbbd
0 1 0 2 0 3 0
5xxxxxxxxxxxxxxxxx9xxxxxxxxxxxxxxxxx9xxxxxxxxxxxxxxxxx6
0 613.23236243236 0 613.23236243236 0 613.23236243236 0
3xxxxxxxxxxxxxxxxx8xxxxxxxxxxxxxxxxx8xxxxxxxxxxxxxxxxx4
```
### Testing
To run the termtables unit tests, check out this repository and type
```
tox
```
### Other software for terminal tables
* [Rich](https://github.com/willmcgugan/rich)
### License
This software is published under the [GPL-3.0
license](https://www.gnu.org/licenses/gpl-3.0.en.html).
Raw data
{
"_id": null,
"home_page": "https://github.com/nschloe/termtables",
"name": "termtables",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "",
"author": "Nico Schl\u00f6mer",
"author_email": "nico.schloemer@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/86/35/b2a0e5abf04e219c92cdc35af72dfcd157c1f43fda538adc282b34a26357/termtables-0.2.4.tar.gz",
"platform": "",
"description": "<p align=\"center\">\n <a href=\"https://github.com/nschloe/termtables\"><img alt=\"termtables\" src=\"https://nschloe.github.io/termtables/termtables.svg\" width=\"60%\"></a>\n <p align=\"center\">The tables have termed.</p>\n</p>\n\n[![PyPi Version](https://img.shields.io/pypi/v/termtables.svg?style=flat-square)](https://pypi.org/project/termtables)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/termtables.svg?style=flat-square)](https://pypi.org/pypi/termtables/)\n[![GitHub stars](https://img.shields.io/github/stars/nschloe/termtables.svg?logo=github&label=Stars&logoColor=white&style=flat-square)](https://github.com/nschloe/termtables)\n[![PyPi downloads](https://img.shields.io/pypi/dm/termtables.svg?style=flat-square)](https://pypistats.org/packages/termtables)\n\n[![gh-actions](https://img.shields.io/github/workflow/status/nschloe/termtables/ci?style=flat-square)](https://github.com/nschloe/termtables/actions?query=workflow%3Aci)\n[![codecov](https://img.shields.io/codecov/c/github/nschloe/termtables.svg?style=flat-square)](https://codecov.io/gh/nschloe/termtables)\n[![LGTM](https://img.shields.io/lgtm/grade/python/github/nschloe/termtables.svg?style=flat-square)](https://lgtm.com/projects/g/nschloe/termtables)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black)\n\n\ntermtables is a lightweight Python 3 package for pretty-printing tables on the command\nline. Install with\n```\npip install termtables\n```\nThe code\n```python\nimport termtables as tt\nimport numpy\n\nnumpy.random.seed(0)\ndata = numpy.random.rand(5, 2)\n\ntt.print(data)\n# tt.to_string(data) returns the string\n```\nproduces\n\n![table1](https://nschloe.github.io/termtables/table1.png)\n\nYou can control border style, padding, alignment, and various other attributes. For\nexample,\n```python\nimport termtables as tt\n\nheader = [\"a\", \"bb\", \"ccc\"]\ndata = [\n [1, 2, 3], [613.23236243236, 613.23236243236, 613.23236243236]\n]\n\ntt.print(\n data,\n header=header,\n style=tt.styles.markdown,\n padding=(0, 1),\n alignment=\"lcr\"\n)\n```\nproduces\n<!--pytest-codeblocks:expected-output-->\n```\n| a | bb | ccc |\n|-----------------|-----------------|-----------------|\n| 1 | 2 | 3 |\n| 613.23236243236 | 613.23236243236 | 613.23236243236 |\n```\nwhich is useful for copy-pasting into websites that support Markdown (like GitHub).\n\nSee\n[`test/test_termtables.py`](https://github.com/nschloe/termtables/blob/master/test/test_termtables.py)\nfor more examples.\n\nIf the styles in `termtables.styles`\n```\nthin\nthin_thick\nthin_double\nrounded\nrounded_thick\nrounded_double\nthick\nthick_thin\ndouble\ndouble_thin\nbooktabs\n\nascii_thin\nascii_thin_double\nascii_double\nascii_double_thin\nascii_booktabs\n\nmarkdown\n```\naren't good enough for you, simply provide your own\nstyle as a string of length 11 or 15 (the extra 4 including header-separating\ncharacters). For example\n```python\nimport termtables as tt\n\nheader = [\"a\", \"bb\", \"ccc\"]\ndata = [\n [1, 2, 3], [613.23236243236, 613.23236243236, 613.23236243236]\n]\n\ntt.print(\n data,\n header=header,\n style=\"x0123456789abcd\"\n)\n```\nproduces\n<!--pytest-codeblocks:expected-output-->\n```\n1xxxxxxxxxxxxxxxxx7xxxxxxxxxxxxxxxxx7xxxxxxxxxxxxxxxxx2\n0 a 0 bb 0 ccc 0\nabbbbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbbbd\n0 1 0 2 0 3 0\n5xxxxxxxxxxxxxxxxx9xxxxxxxxxxxxxxxxx9xxxxxxxxxxxxxxxxx6\n0 613.23236243236 0 613.23236243236 0 613.23236243236 0\n3xxxxxxxxxxxxxxxxx8xxxxxxxxxxxxxxxxx8xxxxxxxxxxxxxxxxx4\n```\n\n\n### Testing\n\nTo run the termtables unit tests, check out this repository and type\n```\ntox\n```\n\n### Other software for terminal tables\n\n * [Rich](https://github.com/willmcgugan/rich)\n\n### License\nThis software is published under the [GPL-3.0\nlicense](https://www.gnu.org/licenses/gpl-3.0.en.html).\n\n\n",
"bugtrack_url": null,
"license": "GPL-3.0-or-later",
"summary": "Pretty tables in the terminal",
"version": "0.2.4",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "b141aab3d4ad9bc298b0406ed7f5c43d",
"sha256": "0ca860eed8957db0045020bcdfcf6620e188b0d776e8543a57ff539fcfeec26d"
},
"downloads": -1,
"filename": "termtables-0.2.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b141aab3d4ad9bc298b0406ed7f5c43d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 17890,
"upload_time": "2021-05-27T07:23:55",
"upload_time_iso_8601": "2021-05-27T07:23:55.157252Z",
"url": "https://files.pythonhosted.org/packages/f9/51/e56764d0db7ec7b2eb121749e6521a53697e8c1cd55a9d0e4374dd587543/termtables-0.2.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "9a858e608132c52ecfd20eb7bff1ed15",
"sha256": "797c6afeb78abdab97cd5bfbbd2fc1bfbd9630052699dc881b27b334bcc6a73f"
},
"downloads": -1,
"filename": "termtables-0.2.4.tar.gz",
"has_sig": false,
"md5_digest": "9a858e608132c52ecfd20eb7bff1ed15",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 17745,
"upload_time": "2021-05-27T07:23:56",
"upload_time_iso_8601": "2021-05-27T07:23:56.567112Z",
"url": "https://files.pythonhosted.org/packages/86/35/b2a0e5abf04e219c92cdc35af72dfcd157c1f43fda538adc282b34a26357/termtables-0.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-05-27 07:23:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "nschloe",
"github_project": "termtables",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "termtables"
}