pythonasciitabular

How can I pretty-print ASCII tables with Python?


I'm looking for a way to pretty-print tables like this:

=======================
| column 1 | column 2 |
=======================
| value1   | value2   |
| value3   | value4   |
=======================

I've found the asciitable library but it doesn't do the borders, etc. I don't need any complex formatting of data items, they're just strings. I do need it to auto-size columns.

Do other libraries or methods exist, or do I need to spend a few minutes writing my own?


Solution

  • For some reason when I included 'docutils' in my google searches I stumbled across texttable, which seems to be what I'm looking for.