YS-L / csvlens

Command line csv viewer
MIT License
2.49k stars 40 forks source link

piping through csvlens and echoing a column from the selected row on exit #22

Closed cabrrtt closed 1 year ago

cabrrtt commented 1 year ago

Loving csvlens @YS-L. Like @elferherrera suggested, I'm finding this an perfect partner to nushell to browse through csv such as:

ps | to csv | csvlens

What I would love to be able to do is to pipe on from csvlens, meaning that csvlens can take a switch to echo a named column from the selected row on exit. Kind of like a columnar fzf

YS-L commented 1 year ago

Interesting! Haven't thought of piping on from csvlens. Do you mean echoing the value of a particular cell in the table?

cabrrtt commented 1 year ago

Yes, just that. To illustrate, instead of this using fzf:

ps | to csv | fzf | split row ',' | get 0 | kill $in

You might do

ps | to csv | csvlens --echo-column pid | kill $in
cabrrtt commented 1 year ago

Or perhaps that would more logically be --echo-cell

YS-L commented 1 year ago

I like the option --echo-column. Just added that in the main branch.

cabrrtt commented 1 year ago

Just built and tested. This works great @YS-L. Thanks!

miketheman commented 1 year ago

Thanks for this feature! Would you consider an adaptation to allow piping through, so that there's no interactive session, rather emits to stdout immediately?

elferherrera commented 1 year ago

It would be nice if this selection can be done inside csvlens. That one can select a column or a cell and then return the values as a comma separated string

YS-L commented 1 year ago

@miketheman Could you show an example usage without interactivity? csvlens is intended for interactive usage, so I suspect there might be better tools for that purpose.

miketheman commented 1 year ago

@YS-L my example was largely intended for a packaging/testing purpose and automated testing that the compiled binary functions correctly without a human confirmation 😁

YS-L commented 1 year ago

It would be nice if this selection can be done inside csvlens. That one can select a column or a cell and then return the values as a comma separated string

@elferherrera Yes, that makes a lot of sense. Supporting column and cell selection is one of the improvements that I plan to implement.