It is a python module, which helps us to print table on terminal. It is one of the basic python modules for reading and writing text tables in ASCII code. It aims to make the interface as similar as possible like csv module in Python. The texttable module supports both fixed-size tables (where column sizes are pre-determined) and dynamic-size tables (where columns can added or removed).
pip install texttable
- Import required module.
- Create an object of texttable()
- Use set_cols_align() method to create columns.
- Use set_cols_dtype() to set datatype of each column. However, this step is optional.
- Use set_cols_valign() to adjust columns.
- Use add_rows() method to insert rows into the table
- Use draw() method to display the table.
The table illustration would be something like this:
Below is a program based on the above approach:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.