top | item 39867412

How to fix CSV: make it even more U+1F4A9 PILE OF POO

26 points| paulfitz | 1 year ago |getgrist.com

27 comments

order

akira2501|1 year ago

What if my data contains a new line? People focus on the comma then forget the newline is just as significant. That still needs to be escaped and we're right back where we started.

Meanwhile, RFC4180 takes less time to read than this entire article.

paulfitz|1 year ago

Escaping is needed no matter what separators are used, but if a character from the astral plane is always present (like U+1F4A9 PILE OF POO) then you can be pretty sure the software is handling unicode well and isn't corrupting cells without you noticing.

So true about RFC4180. Admittedly this post kind of got out a little early, support for the format was slated for the first of next month...

blackbeans|1 year ago

Ageeed, and the RFC4180 you are referring to also specifies how to escape newlines.

CSV is a simple storage format for data. Its simplicity, readability and portability makes it popular. I think that any attempt to improve it will be a failure.

I must say that CSV generally suffices for table data. The only annoyance is that internationally, there are differences in the use of the column separator, as the comma is often used as decimal separator. I think CSV should always be implemented with a comma as column separator and a dot as decimal separator, regardless of the country. But applications such as Excel do not accept this format internationally.

kristopolous|1 year ago

If we are willing to throw away the comma, use the ASCII RS, record separator symbol. It's exactly what you want, even has a visual ␞ these days.

It's a problem solved decades ago with solutions we've failed to adopt. Weird, buggy, poorly parsable CSV is still somehow the norm.

Not saying you should, but if you want to change, the answer is already there. Change has to start somewhere...

verandaguy|1 year ago

Technically editorialized title (since the original article just uses the emoji verbatim), but I think this is a net improvement.

Retr0id|1 year ago

Emojis are disabled on HN (although in exceptional circumstances, staff have been known to edit them in)

dbt00|1 year ago

0x1d and 0x1e in the ascii standard exist for exactly this reason and don’t need more than one byte unlike this goofy thing.

spiffytech|1 year ago

According to the USV project, these characters don't work out so well in practice.

> We tried using the control characters, and also tried configuring various editors to show the control characters by rendering the control picture characters.

> First, we encountered many difficulties with editor configurations, attempting to make each editor treat the invisible zero-width characters by rendering with the visible letter-width characters.

> Second, we encountered problems with copy/paste functionality, where it often didn't work because the editor implementations and terminal implementations copied visible letter-width characters, not the underlying invisible zero-width characters.

>Third, users were unable to distinguish between the rendered control picture characters (e.g. the editor saw ASCII 31 and rendered Unicode Unit Separator) versus the control picture characters being in the data content (e.g. someone actually typed Unicode Unit Separator into the data content).

https://github.com/SixArm/usv/tree/main/doc/faq#why-use-cont...

hhh|1 year ago

Why do the RS and GS characters get ignored so much? I have only seen them used in symbols on parts labels of one of the big 3 automakers.

axelthegerman|1 year ago

That's great, how does a normal person type that? For a comma I got a key on my keyboard

gwbas1c|1 year ago

I don't think CSV can ever be "fixed." Its popular because there is always someone naive enough to think that it works, and ignorant of specs that handle corner cases.

gwbas1c|1 year ago

I think we should name the files ".cso"

CSO is a stormwater industry term for "Combined Sewer Overflow." They happen in older cities where storm runoff and raw sewage (poop) go into the same sewer system. When there is a lot of rain, the wastewater treatment plants overflow, and then raw sewage runs into waterways.

https://en.wikipedia.org/wiki/Combined_sewer#Combined_sewer_...

dsagal|1 year ago

That should make it the format of choice for Chief Security Officers.

paulfitz|1 year ago

This is excellent, thank you!

dwheeler|1 year ago

No! The poop symbol is used in data, and thus is a terrible separator. If you have to quote it anyway, use commas, as that is already in use. Or use "Unicode" separated values.

deathanatos|1 year ago

You could just apply the standard CSV escaping mechanism, so a single poop in a cell is represented in the file by 4 poop emoji. (Two to quote, one to escape, one as a literal. See RFC 4180 if you're still confused on "why 4?")

ghusto|1 year ago

Perhaps naive, but we escape with \ everywhere else, so why not here?

If you're typing in CSV manually, escape with \

If you're exporting to CSV, the program already know which part is data and which part is the next cell, so again the program can escape with \

deathanatos|1 year ago

Because those of us that have to read your data would highly prefer you just emit standard¹ CSV, and not invent "CSV+my oddball customizations". If you're going to muck about outside the standard format, then you might as well just use DSV from the OP.

Most good implementations are flexible enough that they might be configurable to your proposed pseudo CSV. (Or even DSV. Or USV. Etc.) But I'd rather just not need to, and the sanest default for any CSV library is the standard format.

(Or even better … just emit newline-terminated JSON. Richer format, less craziness than CSV, parsers still abound.)

¹(RFC 4180. "," is field sep, CRLF is row sep. You can escape a comma or a CRLF by surrounding the entire field in double-quotes, and a double quote itself can be escaped by escaping the field, doubling the internal double quote.)

refulgentis|1 year ago

https://webcache.googleusercontent.com/search?q=cache:https:...

n.b. not worth your time. tl;dr: lets replace the comma with the poop emoji because commas occur in data.

There's already a solution to that (obviously). Best argument a contrarian could make is you "learn about unicode", by which they'd mean, the words "basic multilingual plane" are included at one point.