Package pology :: Module tabulate

Module tabulate

Pretty-printing of tabular data.


Author: Chusslove Illich (Часлав Илић) <caslav.ilic@gmx.net>

License: GPLv3

Functions
string/ColorString
tabulate(data, coln=None, rown=None, dfmt=None, space=' ', none='', rotated=False, colorize=False, indent='', colnra=False, rownra=False, colw=0)
Tabulate data in plain text.
Variables
  __package__ = 'pology'
Function Details

tabulate(data, coln=None, rown=None, dfmt=None, space=' ', none='', rotated=False, colorize=False, indent='', colnra=False, rownra=False, colw=0)

 

Tabulate data in plain text.

All data fields can have missing trailing entries. They will be set to None according to table extents.

Examples:

>>> print T.tabulate(data=((1, 4), (2, ), (3, 6)),
...                  coln=("c1", "c2", "c3"), rown=("r1", "r2"),
...                  space="  ", none="-")
-   c1  c2  c3
r1   1   2   3
r2   4   -   6
Parameters:
  • data ([[string*]*]) - column entries (cells) by column
  • coln ([string*]) - column names
  • rown ([string*]) - row names
  • dfmt ([string*]) - format strings per column (e.g. "%+.2f" for floats)
  • space (string) - fill-in for spacing between cells
  • none (string) - fill-in for displaying empty cells (i.e. None-valued)
  • rotated (bool) - whether the table should be transposed
  • colorize (bool) - whether the table should have color highlighting
  • indent (string) - indent string for the whole table
  • colnra (bool) - right align column names
  • rownra (bool) - right align row names
  • colw (integer) - minimal column width
Returns: string/ColorString
plain text representation of the table (no trailing newline)