So You Want to Write Your Own CSV code (tburette.github.io)
recommended by 2 users | 2014 | 158 points by Monkeyget | software design | original thread |
2 users recommended this thread. What they said:
tyingq Aug 30, 2018 | on: All software sucks (2011) | context

A pretty good summary of the sort of "deceptive simplicity" around csv: http://thomasburette.com/blog/2014/05/25/so-you-want-to-writ...

And the related HN discussion: https://news.ycombinator.com/item?id=7796268

ignoramous Jun 8, 2017 | on: Show HN: Npm module that makes easy to convert JSON to CSV | context

There was an interesting article abt CSV parsing a few years ago, here's the HN discussion https://news.ycombinator.com/item?id=7796268

To quote the top most comment (by user, slg): "CSV are a headache. Like the article says, RFC4180 doesn't necessarily represent the real world. However sometimes you just have to reject things that aren't spec.

Not too long ago I was struggling with one of these CSV issues and received some good advice from Hans Passant [1] on a Stack Overflow question pertaining to my problem (emphasis mine):

'It is pretty important that you don't try to fix it. That will make you responsible for bad data for a long time. Reject the file for being improperly formatted. If they hassle you about it then point out that it is not RFC-4180 compatible. There's another programmer somewhere that can easily fix this.'

It makes perfect sense in hindsight. If you accept a malformed CSV file, people will expect you to accept any malformed data that has a CSV extension. You are taking on a lot of extra responsibility to cover for the lack of work by another programmer. Odds are they can make a change to fix the problem that takes a fraction of the time it would take you work around it. You just have to raise the issue.

I realize that rejecting bad files isn't really possible in every circumstance. But I have a feeling it is an option more times than you might initially think."