-
Notifications
You must be signed in to change notification settings - Fork 361
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
Separate quote
config for headers and cells
#195
Comments
This protects against cases when someone puts the delimiter into the column name. |
Is there a way to disable this from happening? |
Not at the moment. What issue is being caused by this? |
The software I am importing the CSV file into does not recognize the title columns when they are wrapped in quotes. I figured out a work around, but it would be useful if I could just pass in a parameter which would not wrap the titles in quotes. |
I'd be willing to merge a PR with a feature like that, preferably with tests 👍 you can add it here https://github.com/zemirco/json2csv/blob/master/lib/json2csv.js#L169 |
quote
config for headers and cells
I know that this is tagged as a feature request, but I'm wondering to have another(?) feature similar to this. As @kodybrand mentioned, the resultant CSV generated is:
Can we have an option to enclose all data fields with quotes regardless of data-type (even for integers, float, boolean) like this:
|
Hi @anishxt, Would some preprocessing solve your use case? Something like this (untested code disclaimer 🙂) Imho, json2csv should only convert json to csv. Not change your data types. |
Thank you, @juanjoDiaz, for throwing that bit! Did some adjustments to fit with my case and it worked! Thank you!! 🙂 |
We should decide if we want to implement this for v5. This is essentially a similar request as #420 . I vote against implementing this since the CSV standard defines that the header should use the same format as normal record lines (https://tools.ietf.org/html/rfc4180#section-2). Just because some software was broken 2 years ago is not a good enough reason to go against the standard. @knownasilya thoughts? |
I agree, especially since it can be done with a transform after. |
I'm not sure I agree that the ietf standard defines the header as the same format as rows; it says that "Each field may or may not [my emphasis] be enclosed in double quotes (however some programs, such as Microsoft Excel, do not use double quotes at all)." (or did I miss something?) |
The CSV output is putting double quotes around the column titles.
var csv = json2csv({ data: myCars, fields: fields });
is producing the correct output, but with double quotes around the column titles.
"car","price","color"
"Audi",40000,"blue"
"BMW",35000,"black"
"Porsche",60000,"green"
The text was updated successfully, but these errors were encountered: