Skip to content

Instantly share code, notes, and snippets.

@braindevices
Last active August 5, 2017 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save braindevices/810ec1c7ba27abae76e3bb200886b49f to your computer and use it in GitHub Desktop.
Save braindevices/810ec1c7ba27abae76e3bb200886b49f to your computer and use it in GitHub Desktop.
1–10 11–20 20–30
6940 5839 6007
6615 6957 6314
6169 6877 6224
6142 6324 6210
6492 6685 6961
6908 5964 6475
6604 6387 6192
6189 6860 6090
6444 6162 0
5812 6950 0

>>> print tabulate(table, headers, tablefmt="pipe") align to right and left

item qty
spam 42
eggs 451
bacon 0

no special alignment

item qty
spam 42
eggs 451
bacon 0

both align to right

item qty
spam 42
eggs 451
bacon 0

>>> print tabulate(table, headers, tablefmt="simple")

item qty


spam 42 eggs 451 bacon 0

is like tables formatted by Postgres' psql cli:

>>> print tabulate.tabulate() +--------+-------+ | item | qty | |--------+-------| | spam | 42 | | eggs | 451 | | bacon | 0 | +--------+-------+

>>> print tabulate(table, headers, tablefmt="fancy_grid")

╒════════╤═══════╕ │ item │ qty │ ╞════════╪═══════╡ │ spam │ 42 │ ├────────┼───────┤ │ eggs │ 451 │ ├────────┼───────┤ │ bacon │ 0 │ ╘════════╧═══════╛

>>> print tabulate(table, headers, tablefmt="orgtbl")

| item | qty | |--------+-------| | spam | 42 | | eggs | 451 | | bacon | 0 |

jira follows the conventions of Atlassian Jira markup language:

>>> print tabulate(table, headers, tablefmt="jira") || item || qty || | spam | 42 | | eggs | 451 | | bacon | 0 |

rst formats data like a simple table of the reStructuredText format:

print tabulate(table, headers, tablefmt="rst") ====== ===== item qty ====== ===== spam 42 eggs 451 bacon 0 ====== =====

mediawiki format produces a table markup used in Wikipedia and on other MediaWiki-based sites:

print tabulate(table, headers, tablefmt="mediawiki") {| class="wikitable" style="text-align: left;" |+ |- ! item !! align="right"| qty |- | spam || align="right"| 42 |- | eggs || align="right"| 451 |- | bacon || align="right"| 0 |}

moinmoin format produces a table markup used in MoinMoin_ wikis:

print tabulate(d,headers,tablefmt="moinmoin") || ''' item ''' || ''' quantity ''' || || spam || 41.999 || || eggs || 451 || || bacon || ||

youtrack format produces a table markup used in Youtrack_ tickets:

print tabulate(d,headers,tablefmt="youtrack") || item || quantity || | spam | 41.999 | | eggs | 451 | | bacon | |

textile format produces a table markup used in Textile format:

print tabulate(table, headers, tablefmt='textile') |. item |. qty | |<. spam |>. 42 | |<. eggs |>. 451 | |<. bacon |>. 0 |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment