News for hackers. Stuff that matters.
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by Apreche on Sunday November 10, 2024 @10:33AM (#42100704)
The shortcoming of using the control characters is that there is no easy way to type them on a keyboard. You can trivially edit csv in a text editor.
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by mattpallissard on Sunday November 10, 2024 @10:57AM (#42100818)
It looks like it would just be be ctrl+^, which seems pretty straightforward.
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by dahart on Sunday November 10, 2024 @11:38AM (#42101060)
Straightforward is completely subjective. But a comma is relatively much simpler in an absolute sense.

Ctrl+shift+6 is a 3-key chord, it’s potentially hard to discover (I can’t say I’ve actually ever seen it), it seems likely to be overridden by applications, and caret isn’t a natural separator and is more commonly used for other things, like exponents.

A comma is 1 key on the keyboard, and it’s already a natural separator; the very meaning of comma is separator. Note how many commas are used in this thread compared to the number of record separators. :P

Having to type both ctrl+shift+6 and ctrl+shift+minus a lot seems like a small physical and mental friction compared to using commas and returns each time a character is typed, that adds up to a lot of physical and mental friction over time. Enough that the eventual implication is that you need better tooling than a text editor provides in order to author delimited files, enough that it sort of undermines the idea of having a text file. It’s a mistake to think that because a key chord exists that it’s a solved problem, and a mistake to underestimate the value of making commonly used items as simple as possible, especially if it’s going to affect a lot of different people.

Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by mattpallissard on Sunday November 10, 2024 @11:48PM (#42104649)
While I agree with the sentiment of that, it still seems a lot easier than escaping characters. I would probably opt for a mix. Control separation with new lines
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by dahart on Monday November 11, 2024 @01:22AM (#42104919)
Isn’t escaping a separate orthogonal issue? Or am I misunderstanding your point? Several people have pointed out that the special ascii field separator will have to be escaped if used within a field, just like a comma is. It seems like escaping is an issue either way, and aside from that, a comma is easier in practice than a special character at every level of interaction; discovery, typing, displaying, tooling, printing, standards, etc..?

I would concede that having the special characters inside fields will be less common than having commas inside CSV field is. I guess that is worth a lot even if it doesn’t fully solve the problem.

Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by smarx007 on Sunday November 10, 2024 @11:07AM (#42100865)
ctrl+_ to separate cells, ctrl+^ to separate rows - works perfectly in notepad++.

I think the proposal can be improved by using ctrl+^ followed by a newline as a row separator, it looks much more readable plus will allow various line-based CLI tools to be used unless there are newlines in the cells.

Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by zabzonk on Sunday November 10, 2024 @10:37AM (#42100715)
> no easy way to type them on a keyboard

or probably to see them in the screen in any sensible form.

Also, what to do if you want to embed those ctrl characters in a field? you are likely back to the way that CSV does it with quotes, commas and CRLFs.

Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by velcrovan on Sunday November 10, 2024 @10:56AM (#42100809)
That’s the whole point of having field and record separators as distinct values in ASCII. There is no other valid use for them, so no escaping is necessary. Have you ever used ASCII value 30 for anything, anywhere, in your life?
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by zabzonk on Sunday November 10, 2024 @11:04AM (#42100849)
I have seen no end of CSV data that embeds CSV data in a field. I'm sure this will happen for whatever character format you pick.
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by LegionMammal978 on Sunday November 10, 2024 @11:21AM (#42100955)
Out of curiosity, in which general circumstances do you tend to see this sort of data? A lot of the support I see for ASV/USV/whatever comes from the idea that this is negligibly rare, which has always sounded to me like a dangerous assumption for a general-purpose format.
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by zabzonk on Sunday November 10, 2024 @12:14PM (#42101287)
Some (many?) years ago i wrote a FOSS tool for messing with CSV called CSVfix. People used to mail me CSV files and ask how to parse them. Also, in my general consulting/contracting work I came across all sorts of weird stuff, a lot of it machine-generated.
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by throw0101d on Sunday November 10, 2024 @12:23PM (#42101326)
> I have seen no end of CSV data that embeds CSV data in a field.

So in CSV [1] a record is separated by a CRLF (0x0D 0xA[2]) and a field value is separated by a comma (0x2c). In ADT (ASC?), the record separator is 0x1E and the unit/field separator is 0x1F.

But there are two more separators defined: file (0x1C) and group (0x1D).

I'm not sure if it's defined anywhere, but if if you wish to embed ADT data with-in a ADT file, and have it as part of the CSV-equivalent field (unit), you could say that:

    after the 0x1E record separator, put a group separator (0x1D)
    which will denote the beginning of ADT sequence which will
    be treated as a unit value. The end of the value shall
    ("MUST"?) be denoted by another group separator, after which
    a unit separator will indicate the next field.
The fact that there are four separation characters would allow for some to be used for embedding applications to tell parsers that a new 'level' of parsing is being done.

[1] https://datatracker.ietf.org/doc/html/rfc4180

[2] https://www.man7.org/linux/man-pages/man7/ascii.7.html

Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by evoke4908 on Sunday November 10, 2024 @11:01AM (#42100835)
No, no one has ever used that character because it can't be typed or displayed which is the entire point of the thread you're replying to
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by cornel_io on Sunday November 10, 2024 @12:21PM (#42101318)
Sometimes the content of a cell in e.g. a CSV file will be another CSV file. This inevitably happens with pretty much every format, whether CSV, TSV, JSON, etc, so you'll need some sort of quoting rule no matter what you do.
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by velcrovan on Sunday November 10, 2024 @11:03AM (#42100842)
But that’s my point. The person I responded to was objecting that they might want to use control characters like ASCII 30 as values in a field. As you and I agree, that will never happen.
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by croes on Sunday November 10, 2024 @11:06AM (#42100860)
What about the cases where people don’t want to use it but still do?

People C&P values from a source that includes those characters and they‘ll break your export file

Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by crazygringo on Sunday November 10, 2024 @11:28AM (#42100991)
> There is no other valid use for them, so no escaping is necessary.

Famous last words...

> Have you ever used ASCII value 30 for anything, anywhere, in your life?

No but if this format took off I would be.

And then because text editors start displaying them so the files make sense, people start using them for other purposes, like separating values on a line or copying spreadsheet cells to the clipboard, because it's more "semantic", and those lines get pasted into a field in a tool that exports its data as CSV.

What then?

Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by Asooka on Sunday November 10, 2024 @11:06AM (#42100861)
Technically there is (not sure about easy, most of these require ctrl+shift, but they are on the keyboard):

    CTRL   DEC HEX CHR NAME
    Ctrl-\  28  1C  FS File Separator (Right Arrow)
    Ctrl-]  29  1D  GS Group Separator (Left Arrow)
    Ctrl-^  30  1E  RS Record Separator (Up Arrow)
    Ctrl-_  31  1F  US Unit Separator (Down Arrow)
From https://www3.rocketsoftware.com/bluezone/help/v42/en/bzadmin...

You can type them in the terminal by prefixing with Ctrl-V, so you can enter a record separator by pressing Ctrl-V, Ctrl-Shift-6. Typing Ctrl-\ is tricky because some programs interpret it to mean end of input, e.g. it exits the Python repl, but I don't think that one in particular is super important to type manually. In hindsight if these were assigned to Ctrl-<letter>, they would have been a lot easier to type and use.

Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by zabzonk on Sunday November 10, 2024 @11:20AM (#42100951)
ctrl-letters are used for other things
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by edlebert on Sunday November 10, 2024 @10:35AM (#42100708)
And equally as important, you can cat a CSV file and easily understand it.
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by bediger4000 on Sunday November 10, 2024 @11:04AM (#42100851)
Or concatenate them, or diff or grep.
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by velcrovan on Sunday November 10, 2024 @11:01AM (#42100836)
This is a bit silly. Any modern text editor (whether vim or VSCode or BBEdit or Notepad++ or whatever) is capable of displaying control characters and of copy/pasting them. Keyboard shortcuts for inserting any characters whatsoever are easy to add. And even with CSV files, if you’re editing them by hand rather than manipulating them with code, you’re probably doing it wrong.
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by pvg on Sunday November 10, 2024 @11:47AM (#42101125)
All of this is easy (use the proper editor, configure it for this particular weirdass situation, do something other than the thing you want to do, etc) in a way that’s exactly analogous to ‘you can spin up your own dropbox over the weekend with ftp and rsync’.
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by jiehong on Sunday November 10, 2024 @10:46AM (#42100751)
Maybe you with a hex editor that shows dual pane: hex and text.
Re:ASCII Delimited Text – Not CSV or Tab Delimited Text by NBJack on Sunday November 10, 2024 @10:51AM (#42100781)
I asser that is still not convenient or scalable. You will need to mentally parse each number (two characters) to ensure it is correct. Compare this with a simple glyph (i.e. a single comma) which is easy to eyeball.