How to merge two raws (cells) with prettytable lib in python?

94 Views Asked by At

I would like to know if it is possible to merge the content of two cells with the PrettyTable lib.

I've searched and searched on the net but I didn't find anything ^^ So either the feature doesn't exist or I'm doing my research wrong (not the right keywords for example)

anyway,

Here is my problem:

I would like to merge the content of the cells when they are identical

+----------------+------+----------+
|      Host      | Port | Protocol | 
+----------------+------+----------+
| x.x.x.x        |  80  |   http   |
|                |      |          |
|                |      |          |
+----------------+------+----------+
| x.x.x.x        | 443  |   http   |
|                |      |          |
|                |      |          |
+----------------+------+----------+
| y.y.y.y        |  80  |   http   |
|                |      |          |
+----------------+------+----------+
| z.z.z.z        | 443  |   http   |
|                |      |          |
+----------------+------+----------+

And i would like to have this render :

+----------------+------+----------+
|      Host      | Port | Protocol | 
+----------------+------+----------+
|                |  80  |   http   |
|                |      |          |
|                |      |          |
| x.x.x.x        |------+----------+
|                | 443  |   http   |
|                |      |          |
|                |      |          |
+----------------+------+----------+
| y.y.y.y        |  80  |   http   |
|                |      |          |
+----------------+------+----------+
| z.z.z.z        | 443  |   http   |
|                |      |          |
+----------------+------+----------+

The perfect rendering could be this:

+----------------+------+----------+
|      Host      | Port | Protocol | 
+----------------+------+----------+
|                |  80  |          |
|                |      |          |
|                |      |          |
| x.x.x.x        |------+   http   |
|                | 443  |          |
|                |      |          |
|                |      |          |
+----------------+------+----------+
| y.y.y.y        |  80  |          |
|                |      |          |
+----------------+------+   http   |
| z.z.z.z        | 443  |          |
|                |      |          |
+----------------+------+----------+

I confess I have no idea how to achieve this with the lib, I can't find anything conclusive on the net :/

Do you have any idea?

I confess I have no idea how to achieve this with the lib, I can't find anything conclusive on the net :/

0

There are 0 best solutions below