d3-dsv icon indicating copy to clipboard operation
d3-dsv copied to clipboard

Option to quote empty strings?

Open nrabinowitz opened this issue 4 years ago • 1 comments

Right now there's no way to distinguish between empty strings and missing data in formatted output.

csvFormatRows([['value', 'null', 'undefined', 'string'], [0,null,undefined,'']]);

I'd like this to return:

value
0,,,""

But instead I get:

value
0,,,

nrabinowitz avatar Jul 27 '21 15:07 nrabinowitz

This would need a symmetric option with parsing such that an unquoted empty string is mapped to null (or undefined?) whereas a quoted empty string is mapped to the empty string. Specifically in these two places:

https://github.com/d3/d3-dsv/blob/344677983ac44e7bbf0e2527ad7f0223d66a2f38/src/dsv.js#L105

https://github.com/d3/d3-dsv/blob/344677983ac44e7bbf0e2527ad7f0223d66a2f38/src/dsv.js#L109

mbostock avatar Jul 27 '21 18:07 mbostock