News for hackers. Stuff that matters.
Re:Friends don't let friends export to CSV by hn_throwaway_99 on Monday March 25, 2024 @08:49PM (#39823087)
Totally agree. His arguments are basically "performance!" (which is honestly not important to 99% of CSV export users) and "It's underderspecified!" And while I can agree with the second, at least partly, in the real world the spec is essentially "Can you import it to Excel?". I'm amazed at how much programmers can discount "It already works pretty much everywhere" for the sake of more esoteric improvements.

All that said (and perhaps counter to what I said), I do hope "Unicode Separated Values" takes off. It's essentially just a slight tweak to CSV where the delimiters are special unicode characters, so you don't have to have complicated quoting/escaping logic, and it also supports multiple sheets (i.e. a workbook) in a single file.

Re:Friends don't let friends export to CSV by ryncewynd on Monday March 25, 2024 @08:55PM (#39823135)
Are there unicode characters specifically for delimiters?

If Excel had a standardised "Save as USV" option it would solve so many issues for me.

I get so many broken CSVs from third-parties

Re:Friends don't let friends export to CSV by hiccuphippo on Monday March 25, 2024 @09:09PM (#39823238)
ASCII has characters for unit, record, group and file separator. And a some days ago there was a story here about using the unicode printable representation of these for an editor friendly format.

https://news.ycombinator.com/item?id=39679378

Re:Friends don't let friends export to CSV by fbdab103 on Monday March 25, 2024 @10:50PM (#39823849)
My significantly bigger beef would be all of the auto-formatting Excel does to mangle data. Excel loves to turn entries into dates.

Human genes had to be renamed so as to avoid this Excel features.

Re:Friends don't let friends export to CSV by potatoicecoffee on Tuesday March 26, 2024 @12:27AM (#39824269)
excel now has a prompt so you can tell it to not convert stuff automatically
Re:Friends don't let friends export to CSV by fbdab103 on Tuesday March 26, 2024 @12:33AM (#39824288)
Gasp. Big news. I do not recall ever seeing this, so I wonder if $JOB is running some hilariously outdated version for compatibility with a load bearing VBA script.
Re:Friends don't let friends export to CSV by sgerenser on Tuesday March 26, 2024 @10:54AM (#39828699)
Automatic Data Conversion toggle was only added in the past ~year: https://insider.microsoft365.com/en-us/blog/control-data-con...
Re:Friends don't let friends export to CSV by bhaney on Monday March 25, 2024 @09:09PM (#39823229)
Hell, there's ASCII characters specifically for delimiters. 0x1C to 0x1F are respectively defined as file, group, record, and unit separators. Unicode naturally inherits them all.
Re:Friends don't let friends export to CSV by smcin on Tuesday March 26, 2024 @09:31AM (#39827589)
Except nobody uses them. Another previous discussion: https://news.ycombinator.com/item?id=33935140
Re:Friends don't let friends export to CSV by crq-yml on Monday March 25, 2024 @09:11PM (#39823257)
There are characters from ASCII for delimiting records, which are underused because they cause confusion about whether they should be represented as a state change like a backspace character, or as a glyph. See also: "nobody can agree on the line ending character sequence".

The USV proposal uses additional codepoints introduced in Unicode for the representation of the record delimiters, so they will always look and edit like character glyphs, and nobody is using them for some other purpose. The standardized look of these glyphs is unappealing, and they aren't easy to type, but it's fixable with a font and some editing functions.

Most of the issue hinges on Excel support.

Re:Friends don't let friends export to CSV by samatman on Monday March 25, 2024 @10:15PM (#39823654)
> nobody is using them for some other purpose.

There's a lot of tooling which uses them for their intended purpose, which is to represent the C0 control characters in a font, so they can be printed when they appear in a document. Your editor is probably one of those.

Which is why I consider USV a terrible idea. If I see ␇ in a file, I don't want to be constantly wondering if it's "mention ␇" or "use ␇ to represent \x07". That's why the control pictures block exists: to provide pictographs of invisible control characters. Not to make a cutesy hack "look! it's a picture of a control character pretending to be what it isn't!!" format.

Re:Friends don't let friends export to CSV by rightbyte on Tuesday March 26, 2024 @03:49AM (#39825145)
I don't underatand why this is a question up for debate. You need eye tracking, so that there is a beep when you read the relevant part.
Re:Friends don't let friends export to CSV by ykonstant on Tuesday March 26, 2024 @05:41AM (#39825843)
I agree about USV, it creates confusion where none needs to exist. For personal use, though, it is not that bad to receive a USV: it should be postmarked ".usv" and in any case if you suspect shenanigans you can `grep` for the offending (literally!) unicode characters and `tr` them into proper ASCII separators. Now, if there is nesting in the USV, I give up.

I share the lament: the whole table issue was solved before it became a problem. POSIX divides ASCII into portable and non-portable characters; only portable characters are allowed in the fields and separators are non-portable. If you need nesting, use a portable encoding of the inner table. This scheme repeats indefinitely without escaping hell or exceptions, preventing tons of errors and headache.

Visibility is such a bizarre complaint. Text editors already handle control characters: they handle tabs, they handle newlines, it is not a tremendous, earth-shattering feature request to make them handle separators gracefully.

Re:Friends don't let friends export to CSV by lostlogin on Monday March 25, 2024 @10:05PM (#39823585)
> Are there unicode characters specifically for delimiters?

We could use the HL7 pipe ‘|’ and all enjoy that hell.

Re:Friends don't let friends export to CSV by deathanatos on Monday March 25, 2024 @11:25PM (#39824010)
God, please no.

For those unfamiliar with the atrocity that is HL7v2, the format is essentially CSV, but with the record separator set to a lone CR, and the field separator usually set to |. Usually, because the format lets the consumer of the format redefine it, for whatever reasons. (The first use of the field separator it determines whatever character it will be. Thankfully, the first use is in a fixed spot, so it's determinable, but still. Oh, but we don't know the character encoding until like the 18th field in … and it doesn't necessarily have to be an ASCII superset. So I have no idea what an HL7v2 message in a non-ASCII superset even looks like, or how a parser is even supposed to reasonably parse such a thing. I presume attempt a decoding in all possible decodings, and then see which one matches the embedded character set, and pray nobody can create a polyglot?)

There's also further separators, delimiting within a field.

It also has its own escape sequences, to deal with the above.

… and it is what carries an unfortunate amount of medical data, and is generally how providers interoperate, despite the existence of more civilized standards like FHIR

Re:Friends don't let friends export to CSV by deathanatos on Thursday March 28, 2024 @02:41PM (#39855735)
I've unfortunately had to bless my brain with much more of this standard this week, for some reason.

Did I mention that subcomponents (if you look at it like a CSV, cells are further subdivided into components & subcomponents, so subcomponents are sort of where we hit "cell text", if you want to keep going with that broken analogy) — contain escape sequences, so that you can have things like the field separator. Normal stuff, so far. The escape sequences also include highlighting, binary blobs, and a subset of roff.

Re:Friends don't let friends export to CSV by chaps on Monday March 25, 2024 @10:39PM (#39823785)
My worst nightmare was a semicolon-delimited file. Where one of the columns had hand-typed street names - without quotes.. so "WELLS" was often "WE;;S".

Since it was the only column like that, the # of columns to the left of the annoying column and the # on the right would always stay the same. So it was pretty easy to clean.

Re:Friends don't let friends export to CSV by doctor_eval on Monday March 25, 2024 @10:43PM (#39823811)
It’s been years since I last worked with HL7. Isn’t there also ^ and ~ to deal with?

Hell indeed.

Re:Friends don't let friends export to CSV by lostlogin on Monday March 25, 2024 @11:49PM (#39824109)
There is the white space bs too. Sometimes it matters, sometimes it doesn’t. What type of white space is it?

Seriously rough.

Re:Friends don't let friends export to CSV by alexvoda on Tuesday March 26, 2024 @08:03AM (#39826799)
Isn't that what HL7 stands for? Hell Layer 7 as in the seventh circle of hell.
Re:Friends don't let friends export to CSV by deathanatos on Thursday March 28, 2024 @02:42PM (#39855742)
Yes, there is. Multi-dimensional CSV?
Re:Friends don't let friends export to CSV by hn_throwaway_99 on Monday March 25, 2024 @09:15PM (#39823290)
Yes, this recent discussion has lots of good info and links in the comments: https://news.ycombinator.com/item?id=39679378
Re:Friends don't let friends export to CSV by Dalewyn on Monday March 25, 2024 @10:16PM (#39823665)
>I do hope "Unicode Separated Values" takes off. It's essentially just a slight tweak to CSV where the delimiters are special unicode characters

Commas can be typed by anyone on any keyboard and readable by anyone.

Special Unicode Characters(tm) can't be typed by anyone on any keyboard and readable by noone.

Convenience is a virtue.

Re:Friends don't let friends export to CSV by deathanatos on Monday March 25, 2024 @11:30PM (#39824025)
> Special Unicode Characters(tm) can't be typed by anyone on any keyboard and readable by noone.

While I'm not a fan of USV, I do believe it is type-able on both macOS and Linux¹. The IME's character picker in both OSes contains all of the necessary characters, I think. (I use "␤" in commit messages, occasionally. That was a typed ␤, not copy/pasted from a Google query or such.)

It would be quite tedious, I do admit; reasonably typed by someone, probably not.

I don't normally type out CSVs by hand either, though.

(¹I don't know about Windows as I simply haven't cared about it in years. For all I know, they've grown an IME in the intervening decade.)

Re:Friends don't let friends export to CSV by al_borland on Tuesday March 26, 2024 @12:35AM (#39824302)
Even if the csv isn’t being typed out by hand, when importing into Excel and the delimiter needs to be manually entered, because it isn’t one of the common ones Excel has a radio button for… it is nice to be able to easily type it.
Re:Friends don't let friends export to CSV by deathanatos on Tuesday March 26, 2024 @12:55PM (#39830097)
While I can see a convenience argument for the somewhat contrived case of typing an entire file out by hand, entering the character once for the import does not seem like a great bar.

> it is nice to be able to easily type it.

Again, that's where an IME is helpful; on the OSes I mention, it's "␞" is:

  macOS: ⌘+^+Space, "record", <arrows to select>, Enter
  Linux: Super+e, "record", Space, Space, <arrows>, Enter
The process is highly visual on both, so you're getting feedback about whether you're about to hit the right character, or not.

(And like, if you have the file, you can always ^C ^V the character, if say you don't know how to IME, or you don't know what the name of the char is, etc.…)

Re:Friends don't let friends export to CSV by bee_rider on Tuesday March 26, 2024 @12:06AM (#39824197)
Would it be possible to just type the file using commas, semicolons, or pipes or something (whatever you happen to know you don’t have in your file) and then convert them using sed?
Re:Friends don't let friends export to CSV by deathanatos on Tuesday March 26, 2024 @12:59PM (#39830153)
Yes, it would be possible. You'd have to make sure the character didn't appear / no escaping at all was present, which the data may or may not allow.

Might as well just get a dedicated CSV→USV converter, though.

(I have a variant of this problem in JSON→YAML … usually I just shove one into the other & pray, akin to your sed solution.)

Re:Friends don't let friends export to CSV by Dalewyn on Tuesday March 26, 2024 @01:04AM (#39824421)
Any character within reason can certainly be entered by way of Character Map in Windows or its equivalent in Linux or MacOS, but if you're arguing that then you don't understand the crux of my argument: Convenience is a virtue.

There is value in the delimiter simply being a key on practically any keyboard in existence. Anything that involves something more complicated than just pushing a single button on a keyboard (this includes IMEs) is a non-starter, because convenience is a virtue.

Re:Friends don't let friends export to CSV by adammarples on Tuesday March 26, 2024 @08:18AM (#39826914)
The fact that it is a character on the keyboard is exactly the problem, too. Any character a user can easily enter will definitely end up mixed into your data somewhere.
Re:Friends don't let friends export to CSV by deathanatos on Tuesday March 26, 2024 @12:50PM (#39830037)
> Anything that involves something more complicated than just pushing a single button on a keyboard (this includes IMEs)

My point is that this is merely a more stringent argument; it's now "on a keyboard, and cannot involve dead keys, etc." … which now excludes classic CSV, too, which requires two keys to enter a double quote. (Shift+')

Again, it does require more keys, and it is certainly not convenient, but n keys to me is still n keys. The real question is why one isn't using a proper tool to enter the data, and is instead encoding it by hand, which, again, even for a classic CSV, is basically something I've never done. (… because why would one?)

Re:Friends don't let friends export to CSV by hn_throwaway_99 on Monday March 25, 2024 @10:34PM (#39823753)
I can't remember the last time I, or anyone I've ever worked with for that matter, ever typed up a CSV from scratch. The whole point of USV is that the delimiters can't normally be typed so you don't have to worry about escaping.

USV supports displayable delimiters (see https://github.com/SixArm/usv), so for the much more common case of editing an existing CSV in a text editor, you can just copy and paste.

Re:Friends don't let friends export to CSV by albert_e on Monday March 25, 2024 @11:24PM (#39824005)
Everyone of us was a beginner at some point. The first time we came across CSV format we likely typed it in notepad by hand. A lot of issues with CSVs are also sometimes troubleshooted by hand-- by manually fixing a quote or a comma.

There is value is the ability to do this level of editing and troubleshooting.

Re:Friends don't let friends export to CSV by hn_throwaway_99 on Monday March 25, 2024 @11:44PM (#39824083)
> The first time we came across CSV format we likely typed it in notepad by hand.

Again, I'm not saying CSVs aren't edited by hand in a text editor, I'm saying they aren't created from scratch in a text editor, even by beginners. USVs are easy to edit in a text editor, too, and I tried viewing and editing USVs with a couple different fonts and had no problems.

Re:Friends don't let friends export to CSV by iainmerrick on Tuesday March 26, 2024 @04:54AM (#39825564)
If the separators can't easily be typed, how do you add a new cell?
Re:Friends don't let friends export to CSV by scbrg on Tuesday March 26, 2024 @08:31AM (#39827033)
Nobody can type up a GIF image, or Word document in a Notepad, yet files of both those formats exist. The answer obviously is tooling. If a format with sane separators was common, so would editors that could edit that format be.
Re:Friends don't let friends export to CSV by iainmerrick on Tuesday March 26, 2024 @08:52AM (#39827223)
I was responding to the GP's:

USVs are easy to edit in a text editor

I don't see how that's the case.

If a format with sane separators was common, so would editors that could edit that format be

Sure, but that's a hypothetical future editor, not something that currently exists.

Edit to add: I also disagree with "sane" in that context. New separators won't solve anything. You'll always need escaping/encoding/encapsulation; get that right and everything else follows. JSON is comma-separated and does just fine.

Re:Friends don't let friends export to CSV by hn_throwaway_99 on Tuesday March 26, 2024 @09:50AM (#39827815)
Copy and paste.
Re:Friends don't let friends export to CSV by eviks on Tuesday March 26, 2024 @02:29AM (#39824779)
No we didn't, we likely typed in Excel by double clicking on our first csv
Re:Friends don't let friends export to CSV by hnlmorg on Tuesday March 26, 2024 @03:35AM (#39825089)
I can’t speak for everyone, but I definitely didn’t use Excel.
Re:Friends don't let friends export to CSV by Dalewyn on Monday March 25, 2024 @10:37PM (#39823774)
I've valued the virtue of CSVs being readable by any text editor known to man, and I've occasionally edited them by hand. The pure simplicity of reading and typing commas trumps any value provided by more esoteric configurations.

As for escaping, that's for the subsequent programmers (which could also be me) to figure out. If it is me, I'll deal with it because it keeps things simple.

Re:Friends don't let friends export to CSV by groestl on Tuesday March 26, 2024 @05:10AM (#39825667)
> I've occasionally edited them by hand.

Yeah, usually when the quoting was f'up.

Re:Friends don't let friends export to CSV by diogocp on Monday March 25, 2024 @09:21PM (#39823323)
> in the real world the spec is essentially "Can you import it to Excel?"

And the answer to that is always no. You will it think it's yes because it works for you, but when you send it to someone who has a different Excel version or simply different regional settings, it won't work. The recipient will first have to figure out what dialect you used to export.

Re:Friends don't let friends export to CSV by chaps on Monday March 25, 2024 @09:49PM (#39823482)
"Always no"? What. Really not sure what you mean here when you agree that the possibility of it working exists.

I get the sentiment -- when I request data through FOIA, I will almost always request it as "an excel format" because I know that I'll at least be able to import it. CSV is much less of a guarantee and will have issues -- missing quotes, wrong delimiters, inconsistent column counts, things like that. So requesting "an excel format" implies "make the best effort to give me something that will load in my excel, but without asking what version of excel I have". Removes a fair amount of hassle, especially when it took months to get the data. It also means that if they fuck up the columns by doing a conversion, you have some means of telling them that the data is simply wrong, rather than the data is hard to work with. It does mean dealing with [0-9]+GB sized excel files sometimes, though.

That all said, I prefer to share CSV files. Haven't had much of a problem with it and I can guarantee some consistency from my side. Like, the people I share files with aren't going to know what the hell a parquet file is. A CSV though? Just double click it if you're less technical, or open it up in less if you can use a terminal. It usually compresses well, despite what the author wrote.

Re:Friends don't let friends export to CSV by throwaway2037 on Tuesday March 26, 2024 @12:52AM (#39824364)

   > when I request data through FOIA
Fascinating. Can you share any details? Did you ever think to share some of your interesting finds here on HN as a submission?
Re:Friends don't let friends export to CSV by chaps on Tuesday March 26, 2024 @02:41AM (#39824838)
Re:Friends don't let friends export to CSV by chongli on Tuesday March 26, 2024 @06:01AM (#39825965)
That was a really fascinating story! Thanks for sharing.
Re:Friends don't let friends export to CSV by r-w on Tuesday March 26, 2024 @09:16AM (#39827423)
Wow, what a treasure trove you’ve got there! I’ve subscribed via RSS, in case anything else comes down the pipe :)
Re:Friends don't let friends export to CSV by chaps on Wednesday March 27, 2024 @01:12AM (#39835867)
Thank you! Hopefully by the end of the year but these things can get, strange.
Re:Friends don't let friends export to CSV by Stranger43 on Tuesday March 26, 2024 @01:51AM (#39824607)
At this point i suspect excel is as dangerous as powerpoint to the quest for sharing and improving human knowledge, in that it gives the illusion of allowing people to analyze data but not the tools to make sure they get their data and model lined up correctly.
Re:Friends don't let friends export to CSV by geraldhh on Tuesday March 26, 2024 @05:43AM (#39825860)
otoh it could be instrumental precisely because it is flexible and doesn't require a lot of forethought
Re:Friends don't let friends export to CSV by goatlover on Tuesday March 26, 2024 @02:08AM (#39824685)
If the answer was always no, importing CSVs to Excel wouldn't be an expectation or widely used.
Re:Friends don't let friends export to CSV by kibwen on Tuesday March 26, 2024 @07:04AM (#39826367)
The answer is "always no" because the question is inherently underspecified, precisely because importing things into Excel is more complicated and context-dependent than it appears on the surface.
Re:Friends don't let friends export to CSV by Pikamander2 on Tuesday March 26, 2024 @03:48AM (#39825143)
I've been amazed by how much LibreOffice is at importing CSVs in a sane manner than Excel. Its CSV import prompt is nothing short of the gold standard and puts Excel to shame.

Also, even if the CSV format is completely valid, Excel will still find a way to misinterpret some of your cells in baffling ways, destroying the original data in the process if you don't notice it in time.

Re:Friends don't let friends export to CSV by prox on Tuesday March 26, 2024 @04:49AM (#39825522)
Heck yes, LibreOffice shines when it comes to that. Excel always threw me curveballs a lot.
Re:Friends don't let friends export to CSV by wiz21c on Tuesday March 26, 2024 @05:13AM (#39825683)
Yeah, I can complain about LO in many ways, but the way it opens CSV is much better than Excel. It was developed by a dev, that's for sure.
Re:Friends don't let friends export to CSV by nuc1e0n on Tuesday March 26, 2024 @06:31PM (#39833589)
The root cause of a lot of problems is that Excel's CSV import is garbage.

Someone should write a simple utility modelled on LibreOffice's CSV import dialog that reads in a CSV file and outputs its content as an XLSX file with all the cells formatted as text. Being as how XLSX files are just XML text in a renamed ZIP file and CSV is a very simple format such a project could be written over a weekend.

Network admins could then create a group policy to reassign the CSV file extension to open with the utility instead of Excel. I guess the utility could automatically open the generated XLSX in Excel as well.

This would fix so many data corruption issues across the whole world.

Microsoft themselves could even do this as a powertoy.

Re:Friends don't let friends export to CSV by smcin on Tuesday March 26, 2024 @09:28AM (#39827569)
Yes the LibreOffice CSV import dialog showing you a what-if preview of what you'd get as you play with different settings, is pure amazing.
Re:Friends don't let friends export to CSV by Freak_NL on Tuesday March 26, 2024 @03:49AM (#39825146)
Oh absolutely. Don't forget about the giant mess Microsoft made in countries like the Netherlands, where Excel will refuse to automatically open comma-separated values files (you know, CSV), unless the separator is a semicolon — because someone in the past thought that was how the Dutch did it.

You want people to be able to open your nice and sensible CSV files in Excel? First figure out which arcane locale specific settings you need, then generate those monstrosities and annoy anyone who genuinely expected Unicode comma-separated values.

My solution was to just write a generic spreadsheet writer component in our API and have it generate CSV (normal, comma-separated, UTF-8), XLSX, or ODS. Anyone using Excel just grabs the XLSX output. Generating XLSX and ODS was just a matter of saving a minimal example file for each and figuring out where to write cells and rows. No extra library needed (both file formats are just zipped up XML files), and everybody is happy.

Re:Friends don't let friends export to CSV by roelschroeven on Tuesday March 26, 2024 @06:24AM (#39826096)
Many countries use the comma as decimal separator, and Microsoft in its infinite wisdom thinks that data interchange formats should follow regional formatting settings (that's unbelievably stupid; I'll never understand how such an enormous error not only came to be, but was never corrected). That makes the comma unusable as column separator in those countries for exchange of numerical data.
Re:Friends don't let friends export to CSV by wouldbecouldbe on Tuesday March 26, 2024 @08:22AM (#39826952)
US users have the same in my experience. I've had multiple clients complain the exports are broken, because Excel only imports them (perfectly) but doesn't allow to open them. I thought it was their way of forcing excel files. Iphone & Google Drive no issues.
Re:Friends don't let friends export to CSV by alexvoda on Tuesday March 26, 2024 @07:54AM (#39826727)
On the other hand you can now use Power Query to import perquet data into Excel.
Re:Friends don't let friends export to CSV by resource_waste on Tuesday March 26, 2024 @11:12AM (#39828924)
Whatever situation got you into the "Power" universe was bad.

Warning you about M$, you will soon be an enterprise dev.

Re:Friends don't let friends export to CSV by alexvoda on Wednesday March 27, 2024 @05:02AM (#39836888)
I am not in that universe, on the contrary I try to stay as far away as possible. And I agree with you. However I think the everything-done-in-OLD-Excel universe is worse. Some people will be terminally stuck in Excel but at least they can use new Excel capabilities instead of being stuck with the Excel of 20 years ago.

So why remain stuck importing CSVs into Excel when you can use Power Query to import Parquet. Why remain stuck using VBA in Excel when you can use Python in Excel.

I do not think an Excel user can be convinced to move to things like Jupyter, R, databases, etc. since they won't even make the jump to Access but maybe they can be convinced to use modern features of Excel.

Re:Friends don't let friends export to CSV by resource_waste on Wednesday March 27, 2024 @03:17PM (#39843405)
Sorry man, I can't think of a case where I'd import a CSV into excel, but have the skill level to use powerquery and import parquet.

Like, if you are going to use power query, why not just python? At least this way you arent going to get nailed into a legacy hellhole.

Re:Friends don't let friends export to CSV by pif on Tuesday March 26, 2024 @08:09AM (#39826835)
>> in the real world the spec is essentially "Can you import it to Excel?"

> And the answer to that is always no.

Sorry, you are wrong! You are confusing "No" and "Yes, after a quick setup at most".

Re:Friends don't let friends export to CSV by braiamp on Tuesday March 26, 2024 @08:14AM (#39826876)
Oh oh oh, I have a story about a quick setup. Sent a csv file to someone in the same org. Guy said that it was not opening. Wanted me to come to their office to see. I told them that IT support should fix it, since I can't, and every machine on my OU could read it. I was the bad guy. Yeah, quick setup my ass. Users can't be arsed to understand that their setup isn't properly configured.
Re:Friends don't let friends export to CSV by mcv on Tuesday March 26, 2024 @09:14AM (#39827405)
Yeah, I definitely prefer CSV over Excel. Excel messes with your data. CSV is what it is. Sure, you may not know exactly what that is, and plenty of times I've had to figure out manually how to handle a specific CSV export, but once I've figured that out, it will work. With Excel, there's always the risk that a new value for a string field could also be interpreted as a date.
Re:Friends don't let friends export to CSV by palmfacehn on Tuesday March 26, 2024 @01:00AM (#39824396)
JSON objects as a CSV field has been mostly agreeable for my usage. It would be nice if some of the spreadsheet apps displayed the object tree.
Re:Friends don't let friends export to CSV by djbusby on Tuesday March 26, 2024 @01:32AM (#39824539)
ASCII has had field and record separators since like, forever. Wish we had kept using those.
Re:Friends don't let friends export to CSV by wombatpm on Tuesday March 26, 2024 @02:31AM (#39824789)
No you don’t. It’s a holdover from when files were on tapes. The logic is all inverted too. Record separators were at the beginning of a record. Group and unit separators could then be nested. You really needed a spec for whatever document you were trying to makt
Re:Friends don't let friends export to CSV by rightbyte on Tuesday March 26, 2024 @03:43AM (#39825121)
It doesn't matter if the sentinel byte is after or before each record.

Having it before is nice for syncing byte streams.

Re:Friends don't let friends export to CSV by wombatpm on Tuesday March 26, 2024 @10:24AM (#39828227)
It matters when you trying to roundtrip the data through a text editor because existing tools balk at a 300MB file with a single line.
Re:Friends don't let friends export to CSV by Repulsion9513 on Tuesday March 26, 2024 @05:30PM (#39833095)
You need a "spec" just the same for a CSV: does it have headers, is there a consistent column ordering, etc. Control characters work the exact same as commas and newlines, but you don't have to worry about escaping them because (unless your data is binary or recursive) the control characters won't show up in the data!
Re:Friends don't let friends export to CSV by jdougan on Tuesday March 26, 2024 @05:33PM (#39833126)
Do you have a reference to how this worked?
Re:Friends don't let friends export to CSV by lolive on Tuesday March 26, 2024 @02:23AM (#39824749)
Re:Friends don't let friends export to CSV by josefx on Tuesday March 26, 2024 @02:08AM (#39824688)
Does it have nesting operators? I want to embedd ASCII within my ASCII fields. So I can have a table within my table.
Re:Friends don't let friends export to CSV by vaylian on Tuesday March 26, 2024 @02:27AM (#39824768)
It kind of does. See `man ascii`

* FS (0x1C) file separator

* GS (0x1D) group separator

* RS (0x1E) record separator

* US (0x1F) unit separator

I've never seen these in the wild though.

Re:Friends don't let friends export to CSV by alex_suzuki on Tuesday March 26, 2024 @02:36AM (#39824809)
They‘re used a lot in barcodes, e.g. for delimiting the different fields of a driving license.
Re:Friends don't let friends export to CSV by euroderf on Tuesday March 26, 2024 @04:17AM (#39825297)
That sounds like the premise for an utterly fascinating deep dive.
Re:Friends don't let friends export to CSV by alex_suzuki on Tuesday March 26, 2024 @12:23PM (#39829661)
It‘s quite the rabbit hole, I can assure you.
Re:Friends don't let friends export to CSV by adammarples on Tuesday March 26, 2024 @08:15AM (#39826886)
Not seeing them in the wild is good, it means they will work when you use them. The more they get used the more often you'll find they crop up in the text fields you're trying to separate and the whole csv escaping nightmare will continue.
Re:Friends don't let friends export to CSV by Repulsion9513 on Tuesday March 26, 2024 @05:31PM (#39833111)
If you've got delimited-text embedded inside your delimited-text, you've got a nightmare that escaping can't save you from.

(obligatory https://knowyourmeme.com/memes/xzibit-yo-dawg)

Re:Friends don't let friends export to CSV by dhagberg on Tuesday March 26, 2024 @01:02PM (#39830184)
They're definitely used in ACARS messages that go to every commercial airplane cockpit...
Re:Friends don't let friends export to CSV by lolive on Tuesday March 26, 2024 @02:19AM (#39824734)
A manager: I wish I could have a CSV inside my CSV.

Any sane person: NO!

Re:Friends don't let friends export to CSV by bruce511 on Tuesday March 26, 2024 @04:07AM (#39825241)
Well you might be wrong, but EDI in general and HL7 specifically allow 3 levels of "fields in fields in field".

As long as your parser copes, and as long as you have appropriate structures to import into, its no big deal.

Re:Friends don't let friends export to CSV by iainmerrick on Tuesday March 26, 2024 @04:52AM (#39825547)
So now when I'm exporting data I need to know what nesting level it's going to live at so I can generate the correct separators?

I really think that might be the worst idea I've heard for a while!

Re:Friends don't let friends export to CSV by bruce511 on Thursday March 28, 2024 @10:52AM (#39852329)
It's not toooo bad :) But it's very much a "thing" in the real word. It's called EDI, and it's been around for a long time.
Re:Friends don't let friends export to CSV by josefx on Tuesday March 26, 2024 @02:27AM (#39824771)
base64 encoded fields it is.
Re:Friends don't let friends export to CSV by lolive on Tuesday March 26, 2024 @02:36AM (#39824806)
That was the right answer. You are hired!
Re:Friends don't let friends export to CSV by wiredfool on Tuesday March 26, 2024 @04:42AM (#39825473)
Been there, done the Interop.
Re:Friends don't let friends export to CSV by icedchai on Tuesday March 26, 2024 @09:47AM (#39827770)
About 10 years ago, I worked at a place where we were embedding both XML and JSON in CSV fields.

Then there are always the people who can't generate a valid CSV due to escaping issues...

Nothing is ever simple.

Re:Friends don't let friends export to CSV by ykonstant on Tuesday March 26, 2024 @05:28AM (#39825773)
The POSIX spec defines portable and non-portable ASCII characters, prudently placing the separators in the non-portable set. In order to nest tables, base64 (or whatever portable encoding) code the table into the field. This works much better, easier and more error-free than any escaping strategy.

Regarding visibility in editors, if you are nesting tables I don't think you care too much about manual editing, but if you do, it is easy to setup vim/emacs/vscode to display the ASCII separators. I am being told even notepad++ can display those, there are no excuses.

Re:Friends don't let friends export to CSV by paulddraper on Tuesday March 26, 2024 @01:40AM (#39824571)
USV has a mountain of problems.

And really is in search of a problem to solve.

Re:Friends don't let friends export to CSV by chrisandchris on Tuesday March 26, 2024 @03:41AM (#39825107)
So true. Working with imports/exports in CSV from ERP software. One can't imagine how often "Oh, this import doesn't work. I'll just fix the CSV file" occurs. Try that with some compressed, "esoteric" file, or even CML and users will break it.

Besides all the downsides CSV has, as soon as it's not only machine-machine communication and a human is involved, CSV is just simole enough.

Re:Friends don't let friends export to CSV by likis on Tuesday March 26, 2024 @03:49AM (#39825151)
It seems like you missed the conclusion in the article. If users want CSV exports, let them have it.

If you have important data being shuffled around systems, pick something with a specification instead.

Re:Friends don't let friends export to CSV by xeromal on Tuesday March 26, 2024 @08:23AM (#39826968)
Check out Polars in python if you want some CSV performance lol. I recently got a 5 million row CSV from a 3rd party and I could manipulate columns (filtering, sorting, grouping) in actions that took less than a second. It's an incredible tool.
Re:Friends don't let friends export to CSV by medstrom on Tuesday March 26, 2024 @09:21AM (#39827489)
The IANA standard for TSV already disallows tabs inside fields, so you can skip writing any quoting logic (in principle). The MIME type is `text/tab-separated-values`.

https://www.iana.org/assignments/media-types/text/tab-separa...

Re:Friends don't let friends export to CSV by puppymaster on Tuesday March 26, 2024 @09:58AM (#39827890)
ditto. if it fits in the ram, file types don't matter.