grid (complex)ΒΆ

see:http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#grid-tables

These python commands:

1
2
3
4
5
6
7
8
import pyRestTable
t = pyRestTable.Table()
t.labels = ('one', 'two', 'three' )
t.rows.append( ['1,1', '1,2', '1,3',] )
t.rows.append( ['2,1', '2,2', '2,3',] )
t.rows.append( ['3,1', '3,2', '3,3',] )
t.rows.append( ['4,1', '4,2', '4,3',] )
print(t.reST(fmt='grid'))

build this table in reST source code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
+-----+-----+-------+
| one | two | three |
+=====+=====+=======+
| 1,1 | 1,2 | 1,3   |
+-----+-----+-------+
| 2,1 | 2,2 | 2,3   |
+-----+-----+-------+
| 3,1 | 3,2 | 3,3   |
+-----+-----+-------+
| 4,1 | 4,2 | 4,3   |
+-----+-----+-------+

which is rendered as:

one two three
1,1 1,2 1,3
2,1 2,2 2,3
3,1 3,2 3,3
4,1 4,2 4,3

Note

API Changes

  • version 2015.1111.01

    In versions previous to 2015.1111.01, the complex output table format was supported:

    print t.reST(fmt='complex')
    

    The complex output format has been aliased grid to be consistent with the docutils [1] documentation:

    print(t.reST(fmt='grid'))
    

    The two commands are identical (except the latter is upgraded for compatibility with Python v3). To preserve existing code, no plans are made to deprecate the complex name.