{ "info": { "author": "Sergey Astanin", "author_email": "s.astanin@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries" ], "description": "python-tabulate\n===============\n\nPretty-print tabular data in Python, a library and a command-line\nutility.\n\nThe main use cases of the library are:\n\n- printing small tables without hassle: just one function call,\n formatting is guided by the data itself\n- authoring tabular data for lightweight plain-text markup: multiple\n output formats suitable for further editing or transformation\n- readable presentation of mixed textual and numeric data: smart\n column alignment, configurable number formatting, alignment by a\n decimal point\n\nInstallation\n------------\n\nTo install the Python library and the command line utility, run:\n\n pip install tabulate\n\nThe command line utility will be installed as `tabulate` to `bin` on\nLinux (e.g. `/usr/bin`); or as `tabulate.exe` to `Scripts` in your\nPython installation on Windows (e.g.\n`C:\\Python27\\Scripts\\tabulate.exe`).\n\nYou may consider installing the library only for the current user:\n\n pip install tabulate --user\n\nIn this case the command line utility will be installed to\n`~/.local/bin/tabulate` on Linux and to\n`%APPDATA%\\Python\\Scripts\\tabulate.exe` on Windows.\n\nTo install just the library on Unix-like operating systems:\n\n TABULATE_INSTALL=lib-only pip install tabulate\n\nOn Windows:\n\n set TABULATE_INSTALL=lib-only\n pip install tabulate\n\nThe module provides just one function, `tabulate`, which takes a list of\nlists or another tabular data type as the first argument, and outputs a\nnicely formatted plain-text table:\n\n >>> from tabulate import tabulate\n\n >>> table = [[\"Sun\",696000,1989100000],[\"Earth\",6371,5973.6],\n ... [\"Moon\",1737,73.5],[\"Mars\",3390,641.85]]\n >>> print(tabulate(table))\n ----- ------ -------------\n Sun 696000 1.9891e+09\n Earth 6371 5973.6\n Moon 1737 73.5\n Mars 3390 641.85\n ----- ------ -------------\n\nThe following tabular data types are supported:\n\n- list of lists or another iterable of iterables\n- list or another iterable of dicts (keys as columns)\n- dict of iterables (keys as columns)\n- two-dimensional NumPy array\n- NumPy record arrays (names as columns)\n- pandas.DataFrame\n\nExamples in this file use Python2. Tabulate supports Python3 too.\n\n### Headers\n\nThe second optional argument named `headers` defines a list of column\nheaders to be used:\n\n >>> print(tabulate(table, headers=[\"Planet\",\"R (km)\", \"mass (x 10^29 kg)\"]))\n Planet R (km) mass (x 10^29 kg)\n -------- -------- -------------------\n Sun 696000 1.9891e+09\n Earth 6371 5973.6\n Moon 1737 73.5\n Mars 3390 641.85\n\nIf `headers=\"firstrow\"`, then the first row of data is used:\n\n >>> print(tabulate([[\"Name\",\"Age\"],[\"Alice\",24],[\"Bob\",19]],\n ... headers=\"firstrow\"))\n Name Age\n ------ -----\n Alice 24\n Bob 19\n\nIf `headers=\"keys\"`, then the keys of a dictionary/dataframe, or column\nindices are used. It also works for NumPy record arrays and lists of\ndictionaries or named tuples:\n\n >>> print(tabulate({\"Name\": [\"Alice\", \"Bob\"],\n ... \"Age\": [24, 19]}, headers=\"keys\"))\n Age Name\n ----- ------\n 24 Alice\n 19 Bob\n\n### Row Indices\n\nBy default, only pandas.DataFrame tables have an additional column\ncalled row index. To add a similar column to any other type of table,\npass `showindex=\"always\"` or `showindex=True` argument to `tabulate()`.\nTo suppress row indices for all types of data, pass `showindex=\"never\"`\nor `showindex=False`. To add a custom row index column, pass\n`showindex=rowIDs`, where `rowIDs` is some iterable:\n\n >>> print(tabulate([[\"F\",24],[\"M\",19]], showindex=\"always\"))\n - - --\n 0 F 24\n 1 M 19\n - - --\n\n### Table format\n\nThere is more than one way to format a table in plain text. The third\noptional argument named `tablefmt` defines how the table is formatted.\n\nSupported table formats are:\n\n- \"plain\"\n- \"simple\"\n- \"github\"\n- \"grid\"\n- \"fancy\\_grid\"\n- \"pipe\"\n- \"orgtbl\"\n- \"jira\"\n- \"presto\"\n- \"psql\"\n- \"rst\"\n- \"mediawiki\"\n- \"moinmoin\"\n- \"youtrack\"\n- \"html\"\n- \"latex\"\n- \"latex\\_raw\"\n- \"latex\\_booktabs\"\n- \"textile\"\n\n`plain` tables do not use any pseudo-graphics to draw lines:\n\n >>> table = [[\"spam\",42],[\"eggs\",451],[\"bacon\",0]]\n >>> headers = [\"item\", \"qty\"]\n >>> print(tabulate(table, headers, tablefmt=\"plain\"))\n item qty\n spam 42\n eggs 451\n bacon 0\n\n`simple` is the default format (the default may change in future\nversions). It corresponds to `simple_tables` in [Pandoc Markdown\nextensions](http://johnmacfarlane.net/pandoc/README.html#tables):\n\n >>> print(tabulate(table, headers, tablefmt=\"simple\"))\n item qty\n ------ -----\n spam 42\n eggs 451\n bacon 0\n\n`github` follows the conventions of Github flavored Markdown. It\ncorresponds to the `pipe` format without alignment colons:\n\n >>> print(tabulate(table, headers, tablefmt=\"github\"))\n | item | qty |\n |--------|-------|\n | spam | 42 |\n | eggs | 451 |\n | bacon | 0 |\n\n`grid` is like tables formatted by Emacs'\n[table.el](http://table.sourceforge.net/) package. It corresponds to\n`grid_tables` in Pandoc Markdown extensions:\n\n >>> print(tabulate(table, headers, tablefmt=\"grid\"))\n +--------+-------+\n | item | qty |\n +========+=======+\n | spam | 42 |\n +--------+-------+\n | eggs | 451 |\n +--------+-------+\n | bacon | 0 |\n +--------+-------+\n\n`fancy_grid` draws a grid using box-drawing characters:\n\n >>> print(tabulate(table, headers, tablefmt=\"fancy_grid\"))\n \u2552\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2564\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2555\n \u2502 item \u2502 qty \u2502\n \u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561\n \u2502 spam \u2502 42 \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 eggs \u2502 451 \u2502\n \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 bacon \u2502 0 \u2502\n \u2558\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2567\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255b\n\n`presto` is like tables formatted by Presto cli:\n\n >>> print(tabulate(table, headers, tablefmt=\"presto\"))\n item | qty\n --------+-------\n spam | 42\n eggs | 451\n bacon | 0\n\n`psql` is like tables formatted by Postgres' psql cli:\n\n >>> print(tabulate(table, headers, tablefmt=\"psql\"))\n +--------+-------+\n | item | qty |\n |--------+-------|\n | spam | 42 |\n | eggs | 451 |\n | bacon | 0 |\n +--------+-------+\n\n`pipe` follows the conventions of [PHP Markdown\nExtra](http://michelf.ca/projects/php-markdown/extra/#table) extension.\nIt corresponds to `pipe_tables` in Pandoc. This format uses colons to\nindicate column alignment:\n\n >>> print(tabulate(table, headers, tablefmt=\"pipe\"))\n | item | qty |\n |:-------|------:|\n | spam | 42 |\n | eggs | 451 |\n | bacon | 0 |\n\n`orgtbl` follows the conventions of Emacs\n[org-mode](http://orgmode.org/manual/Tables.html), and is editable also\nin the minor orgtbl-mode. Hence its name:\n\n >>> print(tabulate(table, headers, tablefmt=\"orgtbl\"))\n | item | qty |\n |--------+-------|\n | spam | 42 |\n | eggs | 451 |\n | bacon | 0 |\n\n`jira` follows the conventions of Atlassian Jira markup language:\n\n >>> print(tabulate(table, headers, tablefmt=\"jira\"))\n || item || qty ||\n | spam | 42 |\n | eggs | 451 |\n | bacon | 0 |\n\n`rst` formats data like a simple table of the\n[reStructuredText](http://docutils.sourceforge.net/docs/user/rst/quickref.html#tables)\nformat:\n\n >>> print(tabulate(table, headers, tablefmt=\"rst\"))\n ====== =====\n item qty\n ====== =====\n spam 42\n eggs 451\n bacon 0\n ====== =====\n\n`mediawiki` format produces a table markup used in\n[Wikipedia](http://www.mediawiki.org/wiki/Help:Tables) and on other\nMediaWiki-based sites:\n\n >>> print(tabulate(table, headers, tablefmt=\"mediawiki\"))\n {| class=\"wikitable\" style=\"text-align: left;\"\n |+ \n |-\n ! item !! align=\"right\"| qty\n |-\n | spam || align=\"right\"| 42\n |-\n | eggs || align=\"right\"| 451\n |-\n | bacon || align=\"right\"| 0\n |}\n\n`moinmoin` format produces a table markup used in\n[MoinMoin](https://moinmo.in/) wikis:\n\n >>> print(tabulate(table, headers, tablefmt=\"moinmoin\"))\n || ''' item ''' || ''' quantity ''' ||\n || spam || 41.999 ||\n || eggs || 451 ||\n || bacon || ||\n\n`youtrack` format produces a table markup used in Youtrack tickets:\n\n >>> print(tabulate(table, headers, tablefmt=\"youtrack\"))\n || item || quantity ||\n | spam | 41.999 |\n | eggs | 451 |\n | bacon | |\n\n`textile` format produces a table markup used in\n[Textile](http://redcloth.org/hobix.com/textile/) format:\n\n >>> print(tabulate(table, headers, tablefmt=\"textile\"))\n |_. item |_. qty |\n |<. spam |>. 42 |\n |<. eggs |>. 451 |\n |<. bacon |>. 0 |\n\n`html` produces standard HTML markup:\n\n >>> print(tabulate(table, headers, tablefmt=\"html\"))\n
| item | qty |
|---|---|
| spam | 42 |
| eggs | 451 |
| bacon | 0 |