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

format - add lines for rows and columns when using csv input #411

Closed
danie-dejager opened this issue Aug 16, 2023 · 4 comments · Fixed by #760
Closed

format - add lines for rows and columns when using csv input #411

danie-dejager opened this issue Aug 16, 2023 · 4 comments · Fixed by #760
Labels
bug Something isn't working cmd/format

Comments

@danie-dejager
Copy link

danie-dejager commented Aug 16, 2023

Is your feature request related to a problem? Please describe.
I would like to create a table from CSV input. I use rich-cli to format my CSV output but ideally gum should do that too and I will need one less tool.
Original:
image
using rich-cli:
image

What I'm getting is a table from which I can select a specific line which will get printed to the command line.
image

Describe the solution you'd like
I want gum to format csv or similar input like rich-cli is doing.

Why does gum work below but I cannot format CSV?

echo "## Test:
|Name            |Bool             | Source     |
|----------------|-----------------|------------|
|a1              |Yes              |local	|
|b1              |Yes              |local       |
|c1              |Yes              |local       |
|d1              |Yes              |remote      |
"  | gum format
Name Bool Source
a1 Yes local
b1 Yes local
c1 Yes local
d1 Yes remote

Describe alternatives you've considered
rich-cli can format my CSV input into columns with minimal effort.
https://github.com/Textualize/rich-cli

@piero-vic
Copy link
Contributor

Hi @daniejstriata. You can use gum table -p. It was introduced on #436 so you will need to use the git version of gum.

I think something like this would work for you.

echo "
a1,a2,a3,a4,a5
b1,b2,b3,b4,b5
c1,c2,c3,c4,c5
d1,d2,d3,d4,d5
"  | gum table -p

@danie-dejager
Copy link
Author

I built the binary from git in the main branch and it is working!
I see it assumes that the first row is a header.
image
otherwise I can specify headers:
image

@danie-dejager
Copy link
Author

danie-dejager commented Nov 1, 2023

If I give a header with no data then the column is not drawn.
image

@caarlos0
Copy link
Member

see #760

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cmd/format
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants