4 ms·
I've long wanted a successor to CSV, but this is kinda stupid. People like CSVs because they look good, feel natural even in plaintext. This is the same reason
by SuperHeavy256 3y ago
I've long wanted a successor to CSV, but this is kinda stupid. People like CSVs because they look good, feel natural even in plaintext. This is the same reason that Markdown in successful.
As for including commas in your data, it could just have been managed with a simple escape character like a \, for when there's actually a comma in your data. That's it.
- hermitcrab 3y ago>As for including commas in your data, it could just have been managed with a simple escape character like a \, for when there's actually a comma in your data. That's it. Not quite. What if there is a \ in your data? Then you have to escape that.
- lelanthran 3y ago> Not quite. What if there is a \ in your data? Then you have to escape that. No problem, any character following a `\` is a literal character. `\\` => literal `\`. `\,` => literal comma. `\a` => literal `a`, etc. Parsing this is easy, generating it is easy, and there is only one rule to remember for humans reading or generating it. Each rule added for parsing is one more added complexity and point of failure.
- philipwhiuk 3y agoYou still have to solve this in USV.
- euroderf 3y agoOr two commas in a row can be the escape, without overloading backslash.
- estebank 3y agoThat wouldn't allow for empty fields.
- euroderf 3y agoFour commas in a row.
- greenshackle2 3y agoCan you parse this 2-row CSV: SomeCommas,MoreCommas,OnlyOneComma,ALotOfCommas ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
- euroderf 3y agoPathological cases are never difficult to find for any app.
- greenshackle2 3y agoWrong. Consider the standard backslash escape: represent literal comma as "\,", and literal backslash as "\\". Backslashes are otherwise forbidden. It will be difficult to find pathological cases for this grammar, because they don't exist.
- euroderf 3y agoWell okay, but there's an outer circle of Hell where people write code to manipulate Windows filepaths.
- blackbeans 3y agoI don't see this as a perfect solution, but CSV is not great either. A comma is super common in both text and numbers. Here in Europe we often use commas as decimal separator and use a semicolon as value separator. As a result spreadsheets almost always fail to automatically parse a CSV. I do like the idea of having a dedicated separator character, that would work right worldwide. And then just standardize the use of a dot as decimal separator in these files.