-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option for null to "" #14
Comments
What do you mean exactly? You have a |
Yes, You are correct. |
I don't want to implement surprising features. People, who feed in JSON with Why don't you run a |
Yes, I can do it by either processing my input data or result(csv). |
@fizerkhan , I won't replace |
zeMirco Thanks , I understood. |
I know this is old, but rather than opening a new issue Putting out the text "null" is both surprising and wrong in my opinion. Ideally you would be able to provide a config parameter to control what is generated for null values. |
@timrobertson100 Would an option like |
It's cumbersome, but sure. Better would be just to be able to say "use '\N' for null" which is like MySQL, PostgreSQL etc. Sadly I can't get a CSV with nulls from this library into postgres using the native postgresql COPY loader because of the null handling. |
That is definitely outside of the scope of this library, and much more complicated then is needed here.. |
I'm sorry, but I don't understand why. It's no different to delimiter:
Why is this so out of scope?
I don't mean to be awkward. It's a super nice library but doesn't produce very portable CSV files as it is. |
Ah, ok I thought you were suggesting a DSL.. 😄 Yes, something like |
Thanks @knownasilya and sorry for not just putting that example at the beginning |
So that's well and good, but it won't handle I think the best option would be a generic solution that can be used for any situation, like |
Is an Typically with JSON libraries you have the option to render nulls as A |
Yes it would contain the column name and value, which isn't so much a can of worms 😄.
|
Just remembered about the Described as
In the readme |
defaultValue isn't working. if (val !== undefined) {
var stringifiedElement = JSON.stringify(val); when val is null, the if clause still activates and JSON.stringify converts it to the string 'null' |
@orzarchi could you submit a PR with a failing test? |
@orzarchi that line does not prevent it, see https://github.com/zemirco/json2csv/blob/master/lib/json2csv.js#L155 ( Also the tests make sure that it works here: https://github.com/zemirco/json2csv/blob/master/test/index.js#L241 Also, if |
Created PR #89 with failing test. Will try to fix it as well. |
Ok, I merged the test, so just work off master to get it to pass 👍 Thanks! |
@orzarchi did you have a go at the fix? |
yup, 20 days ago #90. |
Wow, sorry I missed it. Merged. Should have a new version out tomorrow. |
The value 'null' seems to be irrelevant in CSV. It will be nicer if you can automatically convert to empty string "" in CSV file.
It could be even better and generic if it is customizable to any string or any number.
The text was updated successfully, but these errors were encountered: