I am able to create a python PrettyTable with a title and table fields. But, I want to create multiple sections in a single table i.e have multiple header (or html rowspan/ colspan to merge cells inorder to create sections). Any pointers for that?
Currently, I am able to create a table using:
table_fields = ['No','Name', 'Age']
from prettytable import PrettyTable
pt = PrettyTable(table_fields)
pt.padding_width = 1
pt.title = 'Customer Info'
pt.add_row(['1','abc','26'])
pt.add_row(['2','xyz','52'])
Output:
+------------------------------+
| Customer Info |
+------------------------------+
| No | Name | Age |
+------------------------------+
| 1 | abc | 26 |
| 2 | xyz | 52 |
+------------------------------+
Desired Output:
+------------------------------+
| Customer Info |
+------------------------------+
| No | Name | Age |
+------------------------------+
| DEPARTMENT 1 |
+------------------------------+
| 1 | abc | 26 |
| 2 | xyz | 52 |
+------------------------------+
| DEPARTMENT 2 |
+------------------------------+
| 1 | pqr | 44 |
| 2 | def | 31 |
+------------------------------+
Looking for a way to add Department 1 and Department 2 rows in the table.