Live data from Hacker News

A love letter to the CSV format

github.com

241–250 of 711 posts

Re: A love letter to the CSV format

#241
post #116
post #27

Funny how the "specification holds in a tweet" yet manages to miss at least three things: 1) character encoding, 2) BOM or not, 3) header or no header.

Always UTF-8. Never a BOM. Always a header

Great if you're the one producing the CSV yourself.

But if you're ingesting data from other organizations, they will, at one time or another, fuck up every single one of those (as well as the ones mentioned in TFA), no matter how clearly you specify them.

Re: A love letter to the CSV format

#242

Earlier quoted context omitted.

What do you mean? I just push the Record Separator key on my keyboard. /s in case :)

The entire argument against ASCII Delimited Text boils down to "No one bothered to support it in popular editors back in 1984. Because I grew up without it, it is impossible to imagine supporting it today." You need 4 new keyboard shortcuts. Use ctrl+, ctrl+. ctrl+[ ctrl+] You need 4 new character symbols. You need a bit of new formatting rules. Pretty much page breaks decorated with the new symbols. It's really not…

It's more like, "because the industry grew up without it, other approaches gained critical mass."

Path dependence is a thing. Things that experience network effects don't get changed unless the alternative is far superior, and ASCII Delimited Text is not that superior.

Ignoring that and pushing for it anyway will at most achieve an xkcd 927.

Re: A love letter to the CSV format

#243
CSV is awesome for front-end webapps needing to fetch A LOT of data from a server in order to display an information-dense rendering. For that use-case, one controls both sides so the usual serialization issues aren't a problem.

Re: A love letter to the CSV format

#244

Earlier quoted context omitted.

CVS isn't brittle, and I'm not sure what "hacks" you're referring to. If you or your parser just follow RFC4180 (particularly quote every field, and double quoting to cancel-quote), that will get you 90%+ compatibility.

Surely you’ve come across situations where line number 10,000,021 of a 60m line CSV fails to parse because there aren’t enough fields in that line of the file…? The issue is that you can’t definitively know which of the 50 fields is missing, so you have to fail the line or worse the file. In my experience (perhaps more niche than yours since you mentioned it has been your day job), the lack of fall back options makes…

That is a problem, but it is also a problem with XML. Parsing the XML file to discover e.g. unmatching tags is far more CPU and memory expensive than correctly passing a CVS.

In both cases you'd fail the entire file rather than partial recovery.

Re: A love letter to the CSV format

#245

Earlier quoted context omitted.

You claimed that CSV is "easily the most widely supported data format in existence in terms of tools and language support", which is a claim that CSV is better supported than JSON, which is a claim that JSON support is lacking.

Can you import .jsonl files into Google sheets or excel natively?

Importing csvs in excel can be a huge pain due to how excel handles localisation. It can basically alter your data if you are not mindful about that, and I have seen it happening too many times.

Re: A love letter to the CSV format

#246
There is a lot not to like about CSV, for all the reasons given here. The only real positive is that you can easily create, read and edit CSV in an editor.

Personally I think we missed a trick by not using the ASCII US and RS characters:

Columns separated by \u001F (ASCII unit separator).

Rows separated by \u001E (ASCII record separator).

No escaping needed.

More about this at:

https://successfulsoftware.net/2022/04/30/why-isnt-there-a-d...

Re: A love letter to the CSV format

#247

What isn't fun about CSV is quickly written parsers and serializers repeatedly making the common mistake of not handling, or badly handling, quoting. For a long time I was very wary of CSV until I learnt Python and started using it's excellent csv standard library module.

Even widely used libraries that you might expect get it right, don't. (Like Spark, which uses Java style backslash escaping)

Re: A love letter to the CSV format

#248

The best part about csv, anyone can write a parser in 30 minutes meaning that I can take data from the early '90s and import it into a modern web service. The worst part about CSV, anyone can ride a parser in about 30 minutes, meaning that it's very easy to get incorrect implementations, incorrect data, and other strange undefined behaviors. But to be clear json, and yaml also have issues with everyone trying to rein…

until you find someone abusing XSD schemas, or someone designing a "dynamically typed" XML... or sneaks in extra data in comments - happened to me way often than it should.

You know what grinds my gears about using XSD for message definitions? Namespaces. Namespaces are a good idea and were done well in XML, as far as I can see, but with XSD you run into this [problem][1]:

Namespaces are used to qualify tags and attributes in XML elements. But they're also used by XSD to qualify the names of types defined in the schema. A sequence element's type is indicated by the value of its "type" attribute. The attribute value is a string that is the namespace-qualified name of the type.

So, if you want to change the alias of an XML namespace in an XSD schema, you can't just use your XML library's facilities for namespace management. You also have to go find the "type" attributes (but not all of the "type" attributes), parse their values, and do the corresponding alias change in the type name.

Don't use a string for a thing that is not a string! I guess in XML attributes you have no choice. XAML improved on the situation a bit.

[1]: https://github.com/dgoffredo/stag/tree/master/src/stag/xsd-u...

Re: A love letter to the CSV format

#249

There is a lot not to like about CSV, for all the reasons given here. The only real positive is that you can easily create, read and edit CSV in an editor. Personally I think we missed a trick by not using the ASCII US and RS characters: Columns separated by \u001F (ASCII unit separator). Rows separated by \u001E (ASCII record separator). No escaping needed. More about this at: https://successfulsoftware.net/2022/04/…

Welp, now I know my weekend project.

Re: A love letter to the CSV format

#250
post #238

Earlier quoted context omitted.

I remembered seeing a comment like this before, and... comment: https://news.ycombinator.com/item?id=26305052 comment: https://news.ycombinator.com/item?id=39679662 "ASCII Delimited Text – Not CSV or Tab Delimited Text" post [2014]: https://news.ycombinator.com/item?id=7474600 same post [2024]: https://news.ycombinator.com/item?id=42100499 comment: https://news.ycombinator.com/item?id=15440801 (...and many more.) "Th…

>we just need some major text editor to get the ball rolling and start making some attempts to understand these characters Many text editors offer extensions APIs, including Vim, Emacs, Notepad++. But the ideal behavior would be to auto-align record separators and treat unit separators as a special kind of newline. That would allow the file to actually look like a table within the text editor. Input record separator…

I think it would be enough for:

1. the field separator to be shown as a special character

2. the row separator to be (optionally) be interpreted as a linefeed

IIRC 1) is true for Notepad++, but not 2).

Post reply on HN