I am using the tty-table plugin to print a table in my console application
The actual result of table contains many columns with somes contains “0” as a data , see example below
Product | Stock | Country | Price |
---|---|---|---|
Samsung S20 | 0 | Germany | 0 |
Iphone 13 | 0 | England | 0 |
Samsung A71 | 0 | US | 0 |
SOne | 0 | UK | 0 |
I would like to hide columns that have 0 as data for all the rows.
Result should be:
Product | Country |
---|---|
Samsung S20 | Germany |
Iphone 13 | England |
Samsung A71 | US |
SOne | UK |
In my code each row is an array, so the result of rows is an array of arrays : example
[
["Samsung S20",0,"Germany",0],
["Iphone 13",0,"England",0],
["Samsung A71",0,"US",0],
["SOne",0,"UK",0],
]
Can you help me to have something like this :
[
["Samsung S20","Germany"],
["Iphone 13","England"],
["Samsung A71","US"],
["SOne","UK"],
]
Important: The header of table is an array of objects :
[{value:"Product"} , {value:"Stock"} ,{value:"Country"} ,{value:"Price"} }
the appearance of columns depends on their existing on the header array