Re:A love letter to the CSV format
by mort96 on Wednesday March 26, 2025 @01:55PM
(#43484865)
TSV looks incredibly ugly when opened in a text editor unless all values are 7 characters or less.
[ Parent
| on HN ]
There are some specialized text editors for editing files with tabs. https://en.wikipedia.org/wiki/Tab_stop#Dynamic_tab_stops , https://nick-gravgaard.com/elastic-tabstops/ , https://tibleiz.net/code-browser/
If have to use a dedicated tabular data editing program, I may as well use a spreadsheet application. What do the options you propose do better than libreoffice calc?
column -t | less -S
is pretty nice because you can inspect a file or dataset on a server (no X) before downloading, to see if you even want to bother. Or you can pass it along through a series of pipes to just get the rows you want.What part of "the value of CSV is to have something that can be easily viewed and modified in any text editor" do you not understand
I’m not sure where that quote is from but it is incorrect, CSVs aren’t easily viewed or modified in text editors in general (at least not in any way that takes advantage of their tabular nature).
There’s at least a slight chance that tab separated values will look ok in a text editor (although in general, nope).
Set a bigger tab size in the editor, e.g. `:set ts=32` in vim.
Aaaand now I can fit like 3 fields next to each other before they wrap and the field with arbitrary length text still misaligns the field after it
There is at least a chance that the text fields will fit in a tab. If not, a tool like “column” on Linux can be used. There is no chance that a text field will fit inside the width of a comma.
I was about to mention that column [1] is part of util-linux, so perhaps it's Linux specific, but then I noticed this in the FreeBSD man page [2]:
> The column command appeared in 4.3BSD-Reno.
[1]: https://man7.org/linux/man-pages/man1/column.1.html
[2]: https://man.freebsd.org/cgi/man.cgi?query=column&sektion=1
vartabstop can help with per-column width. I found
https://sharats.me/posts/automating-the-vim-workplace-3/#usi...
which greatly improved my TSV editing experience in vim. Couple that with autocmd TextChangedI and you get realtime recalculation and alignment.
Re:A love letter to the CSV format
by solidsnack9000 on Wednesday March 26, 2025 @05:26PM
(#43487509)
How does CSV look when the fields are all of different widths?
Like a list of lists of strings