0

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 :/

nitnit
  • 1
  • Why do you only merge 2 of the rows with `http`? – Kraigolas Nov 28 '22 at 17:22
  • This is not necessarily mandatory on my side since this element only concerns an IP, I just want to be able to (at least) merge the first collones of the hosts if they are similar, because it will be more readable. – nitnit Nov 29 '22 at 10:02

0 Answers0