nice-json2csv icon indicating copy to clipboard operation
nice-json2csv copied to clipboard

Output not compatible with spreadsheet CSV importers

Open wxdu opened this issue 10 years ago • 0 comments

Hi Matteo,

I haven't looked at Excel, but for OpenOffice, at least, it expects double-quotes to be doubled, rather than backslash-escaped, even when the string delimiter is a double quote already. This seems insane to me, but the spreadsheet people claim it's their standard.

Since you're using JSON.stringify, you're outputting backslashed double-quotes.

In order to use your (very useful) package in my project, I added a line to your convertToCsv function, at the end of the string replace chain: .replace(/\"/g, '""');

This is working well for me. I'm not sure if it's something you would want to do by default, since I'm not sure that everyone who uses your package is trying to import into a spreadsheet.

But I thought I would mention it.

Cheers,

Ross Grady

wxdu avatar Jan 05 '15 19:01 wxdu