Interactive example with ipythonΒΆ
Build the table from a dictionary:
1In [1]: import pyRestTable
2
3In [2]: pyRestTable.__version__
4Out[2]: '2020.0.8.dev5+g2e1eee2'
5
6In [3]: t = pyRestTable.Table(dict(x=[1], y=[2]))
7
8In [4]: print(t.reST())
9= =
10x y
11= =
121 2
13= =
which displays as:
x |
y |
---|---|
1 |
2 |
The same table may be rendered in the grid reST format:
1In [8]: print(t.reST(fmt='grid'))
2
3+---+---+
4| x | y |
5+===+===+
6| 1 | 2 |
7+---+---+
which displays as:
x |
y |
---|---|
1 |
2 |
The same table may be rendered in the list-table reST format:
1In [9]: print(t.reST(fmt='list-table'))
2
3.. list-table::
4 :header-rows: 1
5 :widths: 1 1
6
7 * - x
8 - y
9 * - 1
10 - 2
which displays as:
x |
y |
---|---|
1 |
2 |