Live data from Hacker News

A love letter to the CSV format

github.com

431–440 of 711 posts

Re: A love letter to the CSV format

#431
post #385

Earlier quoted context omitted.

Waiting for someone to write a love letter to the infamous Windows INI file format I actually miss that. It was nice when settings were stored right alongside your software, instead of being left behind all over a bloated registry. And the format was elegant, if crude. I wrote my own library for encoding/writing/reading various datatypes and structure into ini's, in a couple different languages, and it served me well…

I feel like YAML is a spiritual successor to the .ini, since it shares a notable ideal of simple human readability/writability.

I think GRON[1] would fit the bill better

[1] https://github.com/tomnomnom/gron

Re: A love letter to the CSV format

#432
post #378

Earlier quoted context omitted.

Depends on what you mean by "better". I would rather software not handle a piece of data at all, than handle it erroneously and changing the data without me realising and thus causing all sorts of issues after.

In practice, web browsers accept the tag soup that is sometimes called html and strict xml-based formats failed.

The browser are not a database (unlike excel). Modifying data before showing it is reversible, modifying it before storing it is not.

Re: A love letter to the CSV format

#433
post #428
post #354

The post should at least mention in passing the major problem with CSV: it is a "no spec" family of de-facto formats, not a single thing (it is an example of "historically grown"). And omission of that meams I'm going to have to call this our for its bias (but then it is a love letter, and love makes blind...). Unlike XML or JSON, there isn't a document defining the grammar of well-formed or valid CSV files, and ther…

While CSV isn't exactly grammared or standardised like XML I think if it as more schema:d than JSON. There might be data corruption or consistency issues, but there is implicitly a schema: every line is exactly n fields, and the first line might contain field names. When a JSON API turns out to have optional fields it usually shows through trial and error, and unlike CSV it's typically not considered a bug you can ex…

JSON is not schema’d per se and intentionally so. There’s jsonschema which has better expressiveness than inference of a tabular schema, as it can reflect relationships.

Re: A love letter to the CSV format

#434
post #224

Earlier quoted context omitted.

They could have just ignored the locale altogether though. Put dots on the numbers when using csv, and assume it has dots when importing

This exactly. Numbers in XLS(X) are (hopefully) not locale-specific – why should they be in CSV?

CSV -> text/csv

Microsoft Excel -> application/vnd.ms-excel

CSV is a text format, xls[x], json, and (mostly) xml are not.

Re: A love letter to the CSV format

#435
post #354

The post should at least mention in passing the major problem with CSV: it is a "no spec" family of de-facto formats, not a single thing (it is an example of "historically grown"). And omission of that meams I'm going to have to call this our for its bias (but then it is a love letter, and love makes blind...). Unlike XML or JSON, there isn't a document defining the grammar of well-formed or valid CSV files, and ther…

People who say that CSV is "simpler" are talking about whatever format Excel exports. Also these people have only ever had to deal with the American Excel localization. So yeah, with the caveat of "only ever use Excel and only ever the American edition" CSV is pretty nice.

Also keeping in mind all the locales where comma is the decimal point…tsv for the world.

Re: A love letter to the CSV format

#437
post #427
post #385

Earlier quoted context omitted.

I feel like YAML is a spiritual successor to the .ini, since it shares a notable ideal of simple human readability/writability.

YAML is readable? No way as there are too many ways to do the same thing and nested structures are unclear to the non trained eye (what is a list? What is nested?), let alone indentation in large files is an issue especially with the default 2 space unreadable standard so many people adhere to. YAML simple? It's sepc is larger than XML... Parsing of numbers and strings is ambiguous, leading zeros are not strings but…

Say "no" to YAML. As a string, if you can.

Re: A love letter to the CSV format

#438
post #389
post #358

Earlier quoted context omitted.

On the off chance you're not being facetious, why not ASCII 0 as a delimiter? (This is a rhetorical question.)

ASCII has characters more or less designed for this 0x1C - File Separator 0x1D - Group Separator 0x1E - Record Separator 0x1F - Unit Separator So I guess 1F would be the "comma" and 1E would be the "newline."

https://stackoverflow.com/questions/8695118/what-are-the-fil...

I am pretty sure you shifted the meaning, the decimal separator is part of the atomic data it does not need a control character.

You would use 1F instead of the comma/semicolon/tab and 1E to split lines (record means line just like in SQL).

You could then use 1D to store multiple CSV tables in a single file.

Re: A love letter to the CSV format

#439

Items #6 to #9 sound like genuine trolling to me; item #8, reversing bytes because of course no other text encodings than ASCII exist, is particularly horrible.

the reversing bytes part is encoding agnostic. you just feed the reversed bytes to the csv parser then re-reverse both the yielded rows and the cells bytes and get the original order of the bytes themselves.

Re: A love letter to the CSV format

#440
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…

Excel is halfway decent if you do the 'import' but not if you just doubleclick on them. It seems to have been programmed to intentionally do stupid stuff with them if you just doubleclick on them.

I agree that the default way Excel handles CSV files is terrible. Using Power Query to manage them is the way to go. But it's the general Microsoft approach to backwards compatibility so very unlikely to change now.
Post reply on HN