News for hackers. Stuff that matters.
Re:A love letter to the CSV format by andrepd on Wednesday March 26, 2025 @01:48PM (#43484788)
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.
Re:A love letter to the CSV format by sundarurfriend on Wednesday March 26, 2025 @02:42PM (#43485426)
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.) "This comes up every single time someone mentions CSV. Without fail." - top reply from burntsushi in that last link, and it remains as true today as in 2017 :D

You're not wrong though, we just need some major text editor to get the ball rolling and start making some attempts to understand these characters, and the rest will follow suit. We're kinda stuck at a local optimum which is clearly not ideal but also not troublesome enough to easily drum up wide support for ADSV (ASCII Delimiter Separated Values).

Re:A love letter to the CSV format by ryandrake on Wednesday March 26, 2025 @03:06PM (#43485731)
Hahah, I came here to make the comment about ASCII's control characters, so I'm glad someone else beat me to it, and also that someone further pointed out that this topic comes up every time someone mentions CSV!
Re:A love letter to the CSV format by scythe on Wednesday March 26, 2025 @05:59PM (#43487895)
>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 as shift+space and unit separator as shift+enter.

Re:A love letter to the CSV format by hermitcrab on Wednesday March 26, 2025 @06:15PM (#43488064)
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).

Re:A love letter to the CSV format by nukem222 on Wednesday March 26, 2025 @09:19PM (#43489458)
Excel needs to default its export to this. Unfortunately excel is proprietary software and therefore fucked.
Re:A love letter to the CSV format by jandrese on Wednesday March 26, 2025 @02:24PM (#43485208)
If there were visible well known characters that could be printed for those and keys on a keyboard for inputting them we would probably have RSV files. Because they are buried down in the nonprintable section of the ASCII chart they are a pain for people to deal with. All it would have taken is one more key on the keyboard, maybe splitting the tab key in half.
Re:A love letter to the CSV format by thesuitonym on Wednesday March 26, 2025 @03:15PM (#43485846)
> If there were visible well known characters that could be printed...

...There would be datasets that include those characters, and so they wouldn't be as useful for record separators. Look into your heart and know it to be true.

Re:A love letter to the CSV format by jandrese on Wednesday March 26, 2025 @05:22PM (#43487456)
I wouldn't feel too bad about blindly scrubbing those characters out of inputs unlike commas, tabs, and quotes.
Re:A love letter to the CSV format by mjevans on Wednesday March 26, 2025 @01:52PM (#43484826)
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.

Re:A love letter to the CSV format by mikepurvis on Wednesday March 26, 2025 @02:04PM (#43484964)
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 by BeFlatXIII on Wednesday March 26, 2025 @07:55PM (#43488910)
Best to add deliberate breakage to the spec, then.
Re:A love letter to the CSV format by immibis on Thursday March 27, 2025 @06:49AM (#43492209)
Graphical representations of the control characters begin at U+2400 in the "Control Pictures" Unicode block. Instead of the actual U+001E Record Separator, you put the U+241E Symbol for Record Separator in the help text.
Re:A love letter to the CSV format by mikepurvis on Thursday March 27, 2025 @09:15AM (#43493287)
.... with a note underneath urging readers not to copy and paste the character because it's only the graphical representation of it, not the thing itself.

Perhaps a more salient example might be CSV nested in CSV. This happens all the time with XML (hello junit) and even JSON— when you plug a USB drive into my LG TV, it creates a metadata file on it that contains {"INFO":"{ \"thing\": true, <etc> }"}

Re:A love letter to the CSV format by immibis on Friday March 28, 2025 @06:20AM (#43503578)
You wouldn't use this format for that. It's not a universal format, but an application-specific one. It works in some applications, not in others.
Re:A love letter to the CSV format by kevmo314 on Wednesday March 26, 2025 @01:53PM (#43484844)
What do you mean? I just push the Record Separator key on my keyboard.

/s in case :)

Re:A love letter to the CSV format by corysama on Wednesday March 26, 2025 @03:27PM (#43486032)
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 that hard.

But, like many problems in tech, the popular advice is "Everyone recognizes the problem and the solution. But, the problematic way is already widely used and the solution is not. Therefore everyone doing anything new should invest in continuing to support the problem forever."

Re:A love letter to the CSV format by WorldMaker on Wednesday March 26, 2025 @04:11PM (#43486682)
In Windows (and DOS EDIT.COM and a few other similarly ancient tools) there have existed Alt+028, Alt+029, Alt+030, and Alt+031 for a long time. I vaguely recall some file format I was working with in QBASIC used some or all of them and I was editing those files for some reason. That was not quite as far back as 1984, but sometime in the early 1990s for sure. I believe EDIT.COM had basic glyphs for them too, but I don't recall what they were, might have been random Wingdings like the playing card suits.

Having keyboard shortcuts doesn't necessarily solve why people don't want to use that format, either.

Re:A love letter to the CSV format by zzo38computer on Wednesday March 26, 2025 @05:30PM (#43487565)
> I believe EDIT.COM had basic glyphs for them too, but I don't recall what they were, might have been random Wingdings like the playing card suits.

That is not specific to EDIT.COM; they are the PC characters with the same codes as the corresponding control characters, so they appear as graphic characters. (They can be used in any program that can use PC character set.)

However, in EDIT.COM and QBASIC you can also prefix a control character with CTRL+P in order to enter it directly into the file (and they appear as graphic characters, since I think the only control characters they will handle as control characters are tabs and line breaks).

Suits are PC characters 3 to 6; these are PC characters 28 to 31 which are other shapes.

Re:A love letter to the CSV format by zzo38computer on Wednesday March 26, 2025 @03:33PM (#43486119)
The keys would be something other than those, though. They would be: CTRL+\ for file separator, CTRL+] for group separator, CTRL+^ for record separator, CTRL+_ for unit separator. Other than that, it would work like you described, I think.

> But, like many problems in tech, the popular advice is "Everyone recognizes the problem and the solution. But, the problematic way is already widely used and the solution is not

This is unfortunately common. However, what else happens too, is disagreement about what is the problem and the solution.

Re:A love letter to the CSV format by LegionMammal978 on Wednesday March 26, 2025 @04:31PM (#43486949)
> 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."

There's also the argument of "Now you have two byte values that cannot be allowed to appear in a record under any circumstances. (E.g., incoming data from uncontrolled sources MUST be sanitized to reject or replace those bytes.)" Unless you add an escaping mechanism, in which case the argument shifts to "Why switch from CSV/TSV if the alternative still needs an escaping mechanism?"

Re:A love letter to the CSV format by zzo38computer on Wednesday March 26, 2025 @05:31PM (#43487578)
One benefit of binary formats is not needing the escaping.
Re:A love letter to the CSV format by LegionMammal978 on Wednesday March 26, 2025 @08:48PM (#43489241)
Length-delimited binary formats do not need escaping. But the usual "ASCII Delimited Text" proposal just uses two unprintable bytes as record and line separators, and the signalling is all in-band.

This means that records must not contain either of those two bytes, or else the format of the table will be corrupted. And unless you're producing the data yourself, this means you have to sanitize the data before adding it, and have a policy for how to respond to invalid data. But maintaining a proper sanitization layer has historically been finicky: just look at all the XSS vulnerabilities out there.

If you're creating a binary format, you can easily design it to hold arbitrary data without escaping. But just taking a text format and swapping out the delimiters does not achieve this goal.

Re:A love letter to the CSV format by immibis on Thursday March 27, 2025 @06:53AM (#43492223)
At least you don't need these values in your data, unlike the comma, which shows up in human-written text.

If you do need these values in your data, then don't use them as delimiters.

Something the industry has stopped doing, but maybe should do again, is restricting characters that can appear in data. "The first name must not contain a record separator" is a quite reasonable restriction. Even Elon Musk's next kid won't be able to violate that restriction.

Re:A love letter to the CSV format by zzo38computer on Thursday March 27, 2025 @11:51AM (#43494909)
I did mean length-delimited binary formats (rather than ASCII formats).
Re:A love letter to the CSV format by oever on Thursday March 27, 2025 @06:39AM (#43492150)
Hear hear! Why is all editing done with text-based editors where humans can make syntax errors. Is it about job security?
Re:A love letter to the CSV format by wat10000 on Wednesday March 26, 2025 @06:01PM (#43487918)
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 by mbreese on Wednesday March 26, 2025 @02:07PM (#43484994)
I’m pretty sure those used to exist.

But when looking for a picture to back up my (likely flawed) memory, Google helpfully told me that you can get a record separator character by hitting Ctrl-^ (caret). Who knew?

Re:A love letter to the CSV format by mbreese on Wednesday March 26, 2025 @02:13PM (#43485085)
And that’s why I tend to use tab delimited files more… when viewed with invisible characters shown, it’s pretty clear to read/write separate fields and have an easier to parse format.

This, of course, assumes that your input doesn’t include tabs or newlines… because then you’re still stuck with the same problem, just with a different delimiter.

Re:A love letter to the CSV format by EGreg on Wednesday March 26, 2025 @02:06PM (#43484983)
Can't there be some magic sequence (like two unescaped newlines) to start a new record?
Re:A love letter to the CSV format by macintux on Wednesday March 26, 2025 @04:55PM (#43487206)
You’ll still find that sequence in data; it’ll just be rare enough that it won’t rear its ugly head until your solution has been in production for a while.
Re:A love letter to the CSV format by andrewflnr on Wednesday March 26, 2025 @01:54PM (#43484851)
Can't type them on a keyboard I guess, or generally work with them in the usual text-oriented tools? Part of the appeal of CSV is you can just open it up in Notepad or something if you need to. Maybe that's more a critique of text tools than it is of ASCII record separator characters.
Re:A love letter to the CSV format by zoover2020 on Wednesday March 26, 2025 @01:53PM (#43484842)
Perhaps the popularity,or lack thereof? More often than not, the bad standard wins the long term market
Re:A love letter to the CSV format by orthoxerox on Wednesday March 26, 2025 @04:31PM (#43486951)
But what if one of your columns contains arbitrary binary data?
Re:A love letter to the CSV format by ndsipa_pomu on Wednesday March 26, 2025 @04:46PM (#43487118)
You'd likely need to uuencode it or similar as CSV isn't designed for binary data.
Re:A love letter to the CSV format by masklinn on Wednesday March 26, 2025 @05:03PM (#43487290)
> I don't get how this is not widely used as standard.

It requires bespoke tools for edition, and while CSV is absolute garbage it can be ingested and produced by most spreadsheet software, as well as databases.

Re:A love letter to the CSV format by marxisttemp on Wednesday March 26, 2025 @07:38PM (#43488791)
I was really excited when I learned of these characters, but ultimately if it’s in ASCII then it’s in-band and will eventually require escaping leading to the same problem.