Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: add a divider option so can separate different rows #460

Open
bcastillo-2022474 opened this issue Jan 10, 2024 · 1 comment
Open

Comments

@bcastillo-2022474
Copy link

bcastillo-2022474 commented Jan 10, 2024

hey, It would be great if you could create add a divider between rows, that way we can for example add the sum of a column below each respective column and separate it with a divider. example:

| xi  | fi | fa | xi*fi | xi-media | (xi-media)^2 | fi*(xi-media)^2 | fg   | fr   | fr% |
|-----|----|----|-------|----------|--------------|-----------------|------|------|-----|
| 160 | 5  | 5  | 800   | 7.32     | 53.5824      | 267.912         | 72.0 | 0.20 | 20  |
| 163 | 3  | 8  | 489   | 4.32     | 18.6624      | 55.9872         | 43.2 | 0.12 | 12  |
| 166 | 2  | 10 | 332   | 1.32     | 1.7424       | 3.4848          | 28.8 | 0.08 | 8   |
| 169 | 6  | 16 | 1014  | 1.68     | 2.8224       | 16.9344         | 86.4 | 0.24 | 24  |
| 172 | 9  | 25 | 1548  | 4.68     | 21.9024      | 197.1216        | 129.6| 0.36 | 36  |
|-----|----|----|-------|----------|--------------|-----------------|------|------|-----|
| 830 | 25 | 64 | 4183  | 19.32    | 98.712       | 541.44          | 360  | 1.00 | 100 |

you can see here that below every column I have the sum of that column. what I would like to be able to do is to add a divider, so I can separate the data visually, like I have it in my example

@tobias-edwards
Copy link

You can add a separator to the penultimate row only e.g.

import { Table } from "console-table-printer";

const table = new Table();
table.addRow({ amount: 1, name: "Apple" });
table.addRow({ amount: 2, name: "Pear" });
table.addRow({ amount: 3, name: "Banana" }, { separator: true });
table.addRow({ amount: 6, name: "Total" });
table.printTable();

Produces:

┌────────┬────────┐
│ amount │   name │
├────────┼────────┤
│      1 │  Apple │
│      2 │   Pear │
│      3 │ Banana │
├────────┼────────┤
│      6 │  Total │
└────────┴────────┘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants