News for hackers. Stuff that matters.
Re:Show HN: Comma Separated Values (CSV) to Unicode Separate... by SuperHeavy256 on Tuesday March 12, 2024 @10:48AM (#39680188)
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.

Re:Show HN: Comma Separated Values (CSV) to Unicode Separate... by hermitcrab on Tuesday March 12, 2024 @11:39AM (#39680822)
>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.

Re:Show HN: Comma Separated Values (CSV) to Unicode Separate... by lelanthran on Tuesday March 12, 2024 @12:33PM (#39681472)
> 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.

Re:Show HN: Comma Separated Values (CSV) to Unicode Separate... by philipwhiuk on Tuesday March 12, 2024 @01:29PM (#39682309)
You still have to solve this in USV.
Re:Show HN: Comma Separated Values (CSV) to Unicode Separate... by euroderf on Tuesday March 12, 2024 @02:28PM (#39683070)
Or two commas in a row can be the escape, without overloading backslash.
Re:Show HN: Comma Separated Values (CSV) to Unicode Separate... by estebank on Tuesday March 12, 2024 @03:00PM (#39683425)
That wouldn't allow for empty fields.
Re:Show HN: Comma Separated Values (CSV) to Unicode Separate... by euroderf on Tuesday March 12, 2024 @03:25PM (#39683772)
Four commas in a row.
Re:Show HN: Comma Separated Values (CSV) to Unicode Separate... by greenshackle2 on Tuesday March 12, 2024 @04:05PM (#39684278)
Can you parse this 2-row CSV:

SomeCommas,MoreCommas,OnlyOneComma,ALotOfCommas

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Re:Show HN: Comma Separated Values (CSV) to Unicode Separate... by euroderf on Tuesday March 12, 2024 @04:58PM (#39684869)
Pathological cases are never difficult to find for any app.
Re:Show HN: Comma Separated Values (CSV) to Unicode Separate... by greenshackle2 on Tuesday March 12, 2024 @05:12PM (#39685020)
Wrong. 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.

Re:Show HN: Comma Separated Values (CSV) to Unicode Separate... by euroderf on Wednesday March 13, 2024 @02:33AM (#39688629)
Well okay, but there's an outer circle of Hell where people write code to manipulate Windows filepaths.
Re:Show HN: Comma Separated Values (CSV) to Unicode Separate... by blackbeans on Tuesday March 12, 2024 @03:53PM (#39684147)
I 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.