A quick example should demonstrate enough about that Plaintable does:
>>> from plaintable import Table
>>> data = [[1, 2, 3, 4, 5],
... [10, 11, 12, 13, 14],
... ['a', 'b', 'c', 'd', 'e'],
... ['a', 'b', 'c', 'd', 'e'],
... [1.0, 2.0, 1.5, 4.25, 10.50]]
>>> headline = ['one', 'two', 'three', 'four', 'five']
>>> table = Table(data, headline, align='r', padding=4,
... floatprec=4)
>>> print(table)
one two three four five
------ ------ ------ ------ -------
1 2 3 4 5
10 11 12 13 14
a b c d e
1.0000 2.0000 1.5000 4.2500 10.5000
You can turn off headline, change alignment, adjust padding, set the float-point precision. There is also a Table.THEMES in place, you change use simple or plain at this moment, for example, just pass theme='plain' as argument.
It needs more customization options, at this moment, the output table is plain text, suitable for human to understand, but not Markdown (Extra) nor reStructuredText, they are not valid table syntaxes.
It possible and is laid on its roadmap, I’d like to see CSV input via command-line is an possible method to use it. A command for format files would be very nice. Speaking for file input, you might want to checkout tabler, which is written in C, a nice tool to have.
Plaintable is written by Stefan Tatschner under the MIT License, currently version 0.1 (2014-04-30), it works on both Python 2 and 3, although only Python 3 is listed on PyPI.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.