moar icon indicating copy to clipboard operation
moar copied to clipboard

Feature Request: Format CSV files

Open gdevenyi opened this issue 1 year ago • 3 comments

lesspipe offers formatting of CSV files, by breaking on comma and using the column command line program to provide easily readable output.

I would like to request moar provide similar formatting functionality.

Colouring the columns (rainbowcsv) is another way which would greatly improve readability of CSVs.

Thanks.

gdevenyi avatar Sep 23 '24 17:09 gdevenyi

I'm not so keen on neither formatting nor calling external tools, but highlighting I think should be there.

I filed a request at https://github.com/alecthomas/chroma/issues/1004 since there seems not to be any CSV highlighter in the library I use.

walles avatar Sep 23 '24 18:09 walles

Setting to help-wanted since they say:

Please note that lexers are contributed by the community. Your best option is to contribute this yourself.

The fastest way to get working CSV highlighting might be to implement it for Chroma.

walles avatar Sep 23 '24 18:09 walles

Made a highlighting PR: https://github.com/alecthomas/chroma/pull/1005

walles avatar Sep 29 '24 07:09 walles

I have given this some thought and I think reformatting CSV files would be too tricky.

There are lots of CSV files out there not conforming to the RFC, so parsing a CSV file will always involve some kind of guesswork.

Guessing wrong and then misformatting would be bad.

So I'll not do this.

Coloring I think should be fine, because getting the coloring wrong is much less bad than getting the formatting wrong. So I think the recoloring PR I made for upstream is still fine, even if that one is bound to get the coloring wrong sometimes. I'll make sure coloring gets included once the upstream PR goes in.

walles avatar Nov 10 '24 11:11 walles

Colouring will make things much more readable, I'm happy with this :+1: thanks.

gdevenyi avatar Nov 11 '24 14:11 gdevenyi