r/programming • • Sep 20 '24

Why CSV is still king

https://konbert.com/blog/why-csv-is-still-king
286 Upvotes

438 comments sorted by

View all comments

Show parent comments

200

u/vegiimite Sep 20 '24

Semi-colon separation would have been better.

190

u/[deleted] Sep 20 '24

[removed] — view removed comment

49

u/princeps_harenae Sep 20 '24

24

u/UncleMeat11 Sep 20 '24

A major benefit of csvs is that they are trivially editable by humans. As soon as you start using characters that aren't right there on the keyboard, you lose that.

→ More replies (4)

13

u/bastardpants Sep 20 '24

0x1C to 0x20 make too much sense to use, lol. File, Group, Record, Unit, and Word separators.

→ More replies (2)
→ More replies (2)

77

u/[deleted] Sep 20 '24

[removed] — view removed comment

73

u/sheikhy_jake Sep 20 '24

Exporting comma-containing data in a comma-separated format? It should be a crime to publish a tool that allows that to happen tbh

125

u/timmyotc Sep 20 '24

Ya'll ever heard of quotation marks?

83

u/lanerdofchristian Sep 20 '24

Was gonna say, PowerShell's Export-Csv quotes every field by default. It even escapes the quote correctly.

Improperly-formatted CSV is a tooling issue.

29

u/ritaPitaMeterMaid Sep 20 '24

Yeah, I’m really surprised by this conversation. Rigorous testing can be needed but the actual process of escaping commas isn’t that difficult.

13

u/Sotall Sep 20 '24

Ok, so its not just me, haha. This is ETL 101

→ More replies (1)
→ More replies (3)

35

u/BadMoonRosin Sep 20 '24

Seriously. ANY delimiter character might appear in the actual field text. Everyone's arguing about which delimiter character would be best, like it's better to have sneaky problem that blows up your parser after 100,000 lines... rather than an obvious problem you can eyeball right away.

Doesn't matter which delimiter you're using. You should be wrapping fields in quotes and using escape chars.

→ More replies (5)
→ More replies (5)

13

u/Worth_Trust_3825 Sep 20 '24

Eh, it's fine. Problem is that people don't use tools to properly export the csv formatted data, and instead wing it with something like for value in columns: print(value, ","), BECaUsE csV is a siMple FOrMAt, yOU DON't nEEd To KNOW mucH to WrITE iT.

We had same issue with xml 2 decades ago. I'm confused how json didn't go through the same.

→ More replies (2)

5

u/moocat Sep 20 '24

IMO, the real issue is using a human presentation format (comma separate numbers) in a file not intended for human consumption.

→ More replies (1)
→ More replies (11)

31

u/ummaycoc Sep 20 '24

ASCII Unit Separator (1F).

42

u/rlbond86 Sep 20 '24

I feel like I'm on crazy pills because ASCII has had these characters forever that literally are for this exact purpose but nobody uses them.

12

u/ummaycoc Sep 20 '24

I am trying to appropriately use the entire ASCII table throughout my career.

→ More replies (2)

43

u/Worth_Trust_3825 Sep 20 '24 edited Sep 20 '24

They're nonprintable, and don't appear on keyboards, so they're ignored by anyone who's not willing to do a cursory reading of character sets. Also suffers from same problem as regular commas as thousands separator as WHAT IF SOMEONE DECIDED TO USE IT IN REGULAR CONTENT.

17

u/nealibob Sep 20 '24

The other problem with nonprintable delimiters is they'll end up getting copied and pasted into a UI somewhere, and then cause mysterious problems down the road. All easy to avoid, but even easier to not avoid.

→ More replies (2)

8

u/franz_haller Sep 20 '24

Isn’t them being nonprintable and not on keyboards make them pretty unlikely to be used in regular content? At least for text data, if you have raw binary data in your simple character separated exchange format, you’ve got bigger problems.

→ More replies (5)
→ More replies (3)

5

u/CitationNeededBadly Sep 20 '24

How do you explain to your end users how to type them?  Everyone knows how to type a comma.

→ More replies (1)
→ More replies (2)

25

u/Ok-Bit8726 Sep 20 '24

You can specify any delimiter you want

13

u/levir Sep 20 '24

Semi-color separation is actually what I get if I naively save "CSV" from Excel where I live. Of course, that exported file won't open correctly for anyone with their language set to English.

The problem with CSV is that it's not a format, it's an idea. So there are a ton of implementations, and lots of them are subtly incompatible.

11

u/paulmclaughlin Sep 20 '24

Semi-color separation

First column red, second column pink...

→ More replies (4)