Live data from Hacker News

A love letter to the CSV format

github.com

11–20 of 711 posts

Re: A love letter to the CSV format

#11
post #7

I'm not really sure why "Excel hates CSV". I import into Excel all the time. I'm sure the functionality could be expanded, but it seems to work fine. The bit of the process I would like improved is nothing to do with CSV - it's that the exporting programs sometimes rearrange the order of fields, and you have to accommodate that in Excel after the import. But since you can have named columns in Excel (make the data in…

It used to silently transform data on import. It used to silently drop columns.

That's it, but it's really bad.

Re: A love letter to the CSV format

#12
post #8
post #2

9. Excel hates CSV It clearly means CSV must be doing something right. This is one area where LibreOffice Calc shines in comparison to Excel. Importing CSVs is much more convenient.

Excel won't import ISO 8601 timestamps either, which is crazy these days where it's the universal standard, and there's no excuse to use anything else. You have to replace the "T" separator with a space and also any trailing "Z" UTC suffix (and I think any other timezone/offset as well?) for Excel to be able to parse as a time/date.

Honestly I’m happier when Excel doesn’t try to convert anything. too much bugginess.

Re: A love letter to the CSV format

#14
CSV is ever so elegant but it has one fatal flaw - quoting has "non-local" effects, i.e. an extra or missing quote at byte 1 can change the meaning of a comma at byte 1000000. This has (at least) two annoying consequences:

1. It's tricky to parallelise processing of CSV. 2. A small amount of data corruption can have a big impact on the readability of a file (one missing or extra quote can bugger the whole thing up).

So these days for serialisation of simple tabular data I prefer plain escaping, e.g. comma, newline and \ are all \-escaped. It's as easy to serialise and deserialise as CSV but without the above drawbacks.

Re: A love letter to the CSV format

#15
post #3
post #2

9. Excel hates CSV It clearly means CSV must be doing something right. This is one area where LibreOffice Calc shines in comparison to Excel. Importing CSVs is much more convenient.

I don't get it - why the world, Excel can't just open the CSV, assume from the extension it's COMMA separated value and do the rest. It does work slightly better when importing, just a little.

Your comma isn't my comma. French systems use the comma as a decimal point for numbers and we use semicolons to separate fields in CSV files.

Re: A love letter to the CSV format

#16
As someone who likes modern formats like parquet, when in doubt, I end up using CSV or JSONL (newline-delimited JSON). Mainly because they are plain-text (fast to find things with just `grep`) and can be streamed.

Most features listed in the document are also shared by JSONL, which is my favourite format. It compresses really well with gzip or zstd. Compression removes some plain-text advantages, but ripgrep can search compressed files too. Otherwise, you can:

  zcat data.jsonl.gz | grep ...


Another advantage of JSONL is that it's easier to chunk into smaller files.

Re: A love letter to the CSV format

#17
post #2

9. Excel hates CSV It clearly means CSV must be doing something right. This is one area where LibreOffice Calc shines in comparison to Excel. Importing CSVs is much more convenient.

Search and replace + text to columns after the fact works fine.

Re: A love letter to the CSV format

#18
post #10

I greatly prefer TSV over CSV. https://en.wikipedia.org/wiki/Tab-separated_values

Agreed, much easier to work with, especially if you can guarantee no embedded tabs or newlines. Otherwise you end up with backslash escaping, but that's still usually easier than quotes.

Re: A love letter to the CSV format

#19

I'm in on the "shit on microsoft for hard to use formats train" but as someone who did a LOT of .docx parsing - it turned into zen when I realized that I can just convert my docs into the easily parsed .html5 using something like pandoc. This is a good blog post and Xan is a really neat terminal tool.

Xan looks great. Miller is another great cli tool for transforming data among csv, tsv, json and other formats.

https://miller.readthedocs/

Re: A love letter to the CSV format

#20
post #10

I greatly prefer TSV over CSV. https://en.wikipedia.org/wiki/Tab-separated_values

The problem with using TSV is different user configuration. For ex. if I use vim then Tab might indeed be a '\t' character but in TextEdit on Mac it might be something different, so editing the file in different programs can yield different formatting. While ',' is a universal char present on all keyboards and formatted in a single way
Post reply on HN