NULL values being skipped
See original GitHub issueI installed your module, and for the most part it is working great. I am pulling data from a database and then feeding the result (in a “simple array” format) into your module to get a “csv” output. However, when I went back and checked the resulting output, I noticed that my data did not match the order from the database.
More specifically, while all “NULL” values were converted to empty strings (it appears, anyway), the cells that contained “NULL” values were being eliminated from the proper order and being shifted to the end of that column’s “csv” results.
Data that is ordered like this in the database:
id name status dateAdded count
1 Bob NULL 1-1-17 NULL
2 Martha NULL 5-21-17 3
3 Paul fired 10-3-17 18
Comes out like this in the csv results:
id,name,status,dateAdded, count 1,Bob,fired,1-1-17 ,3 2,Martha,5-21-17,18 3,Paul,10-3-17,
I have no options set, and am essentially running the function like this:
jsonexport(myjsondata, (err, csv) => { if(err) return console.log(err) return csv } )
Can anyone help me figure out why this is happening? It’s throwing my row data off and making the results unusable to send to clients or other co-workers. Thank you!
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (6 by maintainers)
Top GitHub Comments
FYI pull request #46 is a result of this issue report. I just added more testing measures
Hello, I have encountered the described problem on a Mac (10.15) Empty and null values are skipped and the value from a line below is inserted into the skipped row and the last line is duplicated to fill the empty field at the end.
JSON
[ { "id": 28374928374, "items": [ { "variant_id": 345635638378, "properties": [ { "name": "prop1", "value": "some value1" }, { "name": "prop2empty", "value": "" }, { "name": "prop3", "value": "some value3" }, { "name": "prop4", "value": "some value4" }, { "name": "prop5", "value": "some value5 " }, { "name": "prop6", "value": "some value6" }, { "name": "prop7null", "value": null }, { "name": "prop8", "value": "some value8" } ] } ] } ]
CSV produced by jsonexport
id,items.variant_id,items.properties.name,items.properties.value 28374928374,345635638378,prop1,some value1 28374928374,345635638378,prop2empty,some value3 28374928374,345635638378,prop3,some value4 28374928374,345635638378,prop4,some value5 28374928374,345635638378,prop5,some value6 28374928374,345635638378,prop6,some value8 28374928374,345635638378,prop7null,some value8 28374928374,345635638378,prop8,some value8