Re:Show HN: Npm module that makes easy to convert JSON to CSV
by chc on Thursday June 08, 2017 @04:12PM
(#14516862)
CSV is pretty poorly standardized, but if you're going by RFC-4180, Numbers is definitely right, due to the interaction of two rules:
* double quotes aren't allowed inside a field that isn't double-quoted
* double-quotes that do appear in a field have to be escaped by preceding them with another double quote.
So by RFC-4180, I'm pretty sure ""hehe"" shouldn't be possible, and the way to represent "hehe" with the quotes is """hehe""".
Re:Show HN: Npm module that makes easy to convert JSON to CSV
by codezero on Thursday June 08, 2017 @05:49PM
(#14517437)
Cool, yep, thanks for pointing out the RFC. I don't envy anyone making CSV parsers and basically assume they won't work when I need to use them :)
Re:Show HN: Npm module that makes easy to convert JSON to CSV
by kauegimenes on Thursday June 08, 2017 @05:59PM
(#14517501)
Here is all the logic related to this behavior: https://github.com/kauegimenes/jsonexport/blob/master/lib/co...
Comparing against Numbers (probably a bad comparison?) I am seeing one slightly different result:
If I have a field that is "hehe"
It's encoded as ""hehe""
It looks like Numbers adds the enclosing quotes:
"""hehe"""
I only see enclosing quotes if there's a comma:
"hehe,hehe" -> """hehe,hehe"""
Anyhow, I'm not sure what the "correct" thing to do here is, if there is one, just a heads up!