Skip to content

Keep 0 and false cells in toCSV and quote carriage returns - #180

Open
bardrop wants to merge 1 commit into
mathigon:masterfrom
bardrop-oss:fix/tocsv-falsy-cr
Open

bardrop wants to merge 1 commit into
mathigon:masterfrom
bardrop-oss:fix/tocsv-falsy-cr

Conversation

@bardrop

@bardrop bardrop commented Nov 20, 2026

Copy link
Copy Markdown

Fixes #179.

  • toCSV used x ? \${x}` : '', so 0andfalsebecame empty cells. Now onlyundefinedandnull become empty cells. (NaNnow prints asNaNinstead of an empty cell, like0`.)
  • Fields with \r are now quoted, like fields with \n (RFC 4180 2.6).
toCSV([[0, 1, false, 'a,b', 'x\ry']])
before: ,1,,"a,b",x\ry
after:  0,1,false,"a,b","x\ry"

Test: new toCSV case in test/arrays-test.ts. 2 of its 5 asserts fail before the fix; npm test 37/37 pass after, eslint clean.

Only undefined and null become empty cells. Fields with \r are now
quoted like fields with \n (RFC 4180 2.6).

Fixes mathigon#179
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

toCSV drops 0 and false cells and does not quote carriage returns

1 participant