Live data from Hacker News

A love letter to the CSV format

github.com

41–50 of 711 posts

Re: A love letter to the CSV format

#41
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.

Have you tried using the "from text/csv" importer under the data tab? Where it will import your data into a table. Because that one will import ISO 8601 timestamps just fine.

Re: A love letter to the CSV format

#42

One thing that has changed the game with how I work with CSVs is ClickHouse. It is trivially easy to run a local database, import CSV files into a table, and run blazing-fast queries on it. If you leave the data there, ClickHouse will gradually optimize the compression. It's pretty magical stuff if you work in data science.

I feel the same way about elastic.

That being said I noticed .parquet as an export format option on Shopify recently and an hopeful more providers offer the choice.

Re: A love letter to the CSV format

#43

Excel hates CSV only if you don't use the "From text / csv" function (under the data tab). For whatever reason, it flawlessly manages to import most CSV data using that functionality. It is the only way I can reliably import data to excel with datestamps / formats. Just drag/dropping a CSV file onto a spreadsheet, or "open with excel" sucks.

Yea they seem to have added this about a year ago and it works pretty well, to be fair.

Now if they would just also allow pasting CSV data as “source” it would be great.

Re: A love letter to the CSV format

#44
post #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

Csv suffers from similar encoding and platform specific gotchas surrounding newlines and delimiter escaping.

Re: A love letter to the CSV format

#46
post #18

Earlier quoted context omitted.

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.

It's not really easier than CSV if you can guarantee no commas or newlines.

Much easier to require fields not have tabs than not have commas, though.

Re: A love letter to the CSV format

#47
post #28
post #24

Earlier quoted context omitted.

That would be solved by using the ASCII control chars Record Separator / Unit Separator! I don't get how this is not widely used as standard.

The _entire_ point of a CSV file is that it's fully human readable and write-able. The characters you mention could be used in a custom delimiter variant of the format, but at that point it's back to a binary machine format.

As soon as you give those characters magic meanings then suddenly people will have reason to want to use them— it'll be a CSV containing localization strings for tooltips that contain that character and bam, we'll be back to escaping.

Except the usages of that character will be rare and so potentially way more scary. At least with quotes and commas, the breakages are everywhere so you confront them sooner rather than later.

Re: A love letter to the CSV format

#48

Excel hates CSV only if you don't use the "From text / csv" function (under the data tab). For whatever reason, it flawlessly manages to import most CSV data using that functionality. It is the only way I can reliably import data to excel with datestamps / formats. Just drag/dropping a CSV file onto a spreadsheet, or "open with excel" sucks.

Yea they seem to have added this about a year ago and it works pretty well, to be fair. Now if they would just also allow pasting CSV data as “source” it would be great.

It's a carry over from powerbi actually, separate function entirely.

Re: A love letter to the CSV format

#49
post #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

Well, back in my day, we used tabs for tabs.

But then some folks came along about 15 years ago screaming about spaces, and they won, so now tabs are 2 or 4 spaces.

The law of unintended consequences strikes again!

Note: not meant to denigrate you space supporters out there.

Post reply on HN