{ "info": { "author": "Thibaut Horel", "author_email": "thibaut.horel+tabletext@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Tabletext\n=========\n\n``tabletext`` is a Python library to format (pretty-print) tabular data as text\ntables. Its goal is to be as simple as possible, while allowing optional\ncustomization of the output.\n\n``tabletext`` also comes with a command line utility, ``table`` which formats\nits input into a table and prints it on the standard output.\n\nInstallation\n------------\n\n``tabletext`` is available on Pypi_ and can be installed with:\n\n.. _Pypi: https://pypi.python.org/pypi/tabletext\n\n.. code-block:: bash\n\n $ pip install tabletext\n\nOverview\n--------\n\nLibrary\n~~~~~~~\n\n``tabletext`` exposes a single function, ``to_text`` which in its simplest form\ntakes a list of list (or any sequence_ of sequences_) and format it as a table.\nThe data is assumed to be in `row-major order`_, meaning that the outer\nsequence's elements are the rows of the table.\n\n.. _row-major order: https://en.wikipedia.org/wiki/Row-major_order\n.. _sequence:\n.. _sequences: https://docs.python.org/2/glossary.html#term-sequence\n\n.. code:: python\n\n >>> from tabletext import to_text\n >>> a = [[\"Code\", \"Name\"],\n [\"AD\", \"ANDORRA\"],\n [\"AE\", \"UNITED ARAB EMIRATES\"],\n [\"AF\", \"AFGHANISTAN\"],\n [\"AG\", \"ANTIGUA AND BARBUDA\"]]\n >>> print to_text(a)\n\nwill output the following:\n\n.. code:: bash\n\n \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 Code \u2502 Name \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 AD \u2502 ANDORRA \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 AE \u2502 UNITED ARAB EMIRATES \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 AF \u2502 AFGHANISTAN \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 AG \u2502 ANTIGUA AND BARBUDA \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\nYou can customize the output with optional arguments:\n\n\n.. code:: python\n\n >>> print to_text(a, header=True, corners=\"+\", hor=\"-\", ver=\"|\",\n header_corners=\"+\", header_hor=\"=\",\n header_ver=\"!\", formats=[\">\", \"<\"])\n\nwill output:\n\n.. code:: bash\n\n +======+======================+\n ! Code ! Name !\n +======+======================+\n | AD | ANDORRA |\n +------+----------------------+\n | AE | UNITED ARAB EMIRATES |\n +------+----------------------+\n | AF | AFGHANISTAN |\n +------+----------------------+\n | AG | ANTIGUA AND BARBUDA |\n +------+----------------------+\n | AI | ANGUILLA |\n +------+----------------------+\n\nSee the Documentation_ section for more details about the optional arguments of\nthe ``to_text`` function.\n\nCommand line utility\n~~~~~~~~~~~~~~~~~~~~\n\nThe command line utility reads from its input the table, each line representing\na row, its entries being separated by ``\\t`` characters (configurable) and\noutputs the formatted table to the standard output:\n\n.. code:: bash\n\n $ df -h | tr -s ' ' \\\\t | cut -f1-6 | table --header\n \u2552\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2555\n \u2502 Filesystem \u2502 Size \u2502 Used \u2502 Avail \u2502 Use% \u2502 Mounted \u2502\n \u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561\n \u2502 /dev/sda2 \u2502 25G \u2502 14G \u2502 9.5G \u2502 60% \u2502 / \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 dev \u2502 3.8G \u2502 0 \u2502 3.8G \u2502 0% \u2502 /dev \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 run \u2502 3.8G \u2502 756K \u2502 3.8G \u2502 1% \u2502 /run \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 tmpfs \u2502 3.8G \u2502 1.3M \u2502 3.8G \u2502 1% \u2502 /dev/shm \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 tmpfs \u2502 3.8G \u2502 0 \u2502 3.8G \u2502 0% \u2502 /sys/fs/cgroup \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 /dev/sda1 \u2502 511M \u2502 24M \u2502 488M \u2502 5% \u2502 /boot \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 tmpfs \u2502 3.8G \u2502 372M \u2502 3.5G \u2502 10% \u2502 /tmp \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 /dev/sda3 \u2502 15G \u2502 9.8G \u2502 4.2G \u2502 71% \u2502 /home \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 /dev/sda5 \u2502 77G \u2502 46G \u2502 27G \u2502 64% \u2502 /media/data \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 tmpfs \u2502 774M \u2502 16K \u2502 774M \u2502 1% \u2502 /run/user/1000 \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\nThe available options can be printed with ``table --help`` and closely follow\nthe optional arguments of the library's ``to_text`` function as documented\nhere_.\n\n.. _here: documentation_\n\nDocumentation\n-------------\n\nThe optional arguments of the ``to_text`` function are as follows:\n\n================== ================ ================\nArgument Default Description\n================== ================ ================\n``formats`` ``None`` Format strings for the entries (see\n below)\n``padding`` ``(1, 1)`` Left and right padding lengths\n``corners`` ``\"\u250c\u252c\u2510\u251c\u253c\u2524\u2514\u2534\u2518\"`` Characters to use for the corners\n``hor`` ``\"\u2500\"`` Horizontal separation character\n``ver`` ``\"\u2502\"`` Vertical separation character\n``header`` ``False`` Wether or not to display the first row\n as a header row\n``header_corners`` ``\"\u2552\u2564\u2555\u255e\u256a\u2561\"`` Characters to use for the header row\n corners\n``header_hor`` ``\"\u2550\"`` Horizontal separation character for the\n header row\n\n``header_ver`` ``\"\u2502\"`` Vertical separation character for the\n header row\n================== ================ ================\n\nMore about some options:\n\n* ``formats`` can be either a single format string, in which case it will be\n used for all entries, or a list of format strings, one per column of the\n table. The format strings must follow Python's `format specification`_. Note\n however that you don't have to specify the width since it is automatically\n computed. Useful format strings are ``\"<\"``, ``\">\"`` and ``\"=\"`` for\n left-aligned, right-aligned and centered columns respectively.\n\n* ``corners`` and ``header_corners`` are strings containing the corner\n characters to be used for rows and the header row respectively. Follow the\n same order as in the default values. Alternatively, you can specify only one\n character (that is, a string of length 1) which will be used for all corners.\n\n.. _format specification: https://docs.python.org/2/library/string.html#format-specification-mini-language\n\nRelease history\n---------------\n\n0.1 (2014-08-14)\n~~~~~~~~~~~~~~~~\n\nInitial release", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Thibauth/tabletext", "keywords": null, "license": "GNU GPLv3", "maintainer": null, "maintainer_email": null, "name": "tabletext", "package_url": "https://pypi.org/project/tabletext/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/tabletext/", "project_urls": { "Homepage": "https://github.com/Thibauth/tabletext" }, "release_url": "https://pypi.org/project/tabletext/0.1/", "requires_dist": null, "requires_python": null, "summary": "Python library and command line utility to pretty-print tabular data", "version": "0.1" }, "last_serial": 1190751, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "dd948785e04a25772af103ad6eba1795", "sha256": "7fd53c6acb9641cf0b6641ff9675ce3818d4b0541b9e05e8219c90ffc8512337" }, "downloads": -1, "filename": "tabletext-0.1.tar.gz", "has_sig": false, "md5_digest": "dd948785e04a25772af103ad6eba1795", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6125, "upload_time": "2014-08-14T18:27:52", "url": "https://files.pythonhosted.org/packages/ed/53/4152a8c71531d4b09eb34cfd7cd18f3764a988de4dc9039405f8182dddb7/tabletext-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dd948785e04a25772af103ad6eba1795", "sha256": "7fd53c6acb9641cf0b6641ff9675ce3818d4b0541b9e05e8219c90ffc8512337" }, "downloads": -1, "filename": "tabletext-0.1.tar.gz", "has_sig": false, "md5_digest": "dd948785e04a25772af103ad6eba1795", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6125, "upload_time": "2014-08-14T18:27:52", "url": "https://files.pythonhosted.org/packages/ed/53/4152a8c71531d4b09eb34cfd7cd18f3764a988de4dc9039405f8182dddb7/tabletext-0.1.tar.gz" } ] }