Closed Skuriles closed 6 years ago
@Skuriles could you submit a failing test?
@knownasilya I have the similar error, I've used the example1 in the browser.
var fields = ['car', 'price', 'color'];
var myCars = [
{
"car": "Audi",
"price": 40000,
"color": "blue"
}, {
"car": "BMW",
"price": 35000,
"color": "black"
}, {
"car": "Porsche",
"price": 60000,
"color": "green"
}
];
after the json2csv, I'm creating the Blob object from the resulted string and the first item doesn't contain the quotes. I didn't check what was the reason of error, just switched to papaparse.unparse
, because of lack of time.
Thanks for your input.
Still need a failing test? Or is the example code good enough?
If you have the time, a failing test would be appreciated!
I'm out of office for today... will be at least monday... sorry
it works for me setting the quotes option to ''. Thanks @Skuriles
@knownasilya any update on this issue. I have the same problem
is there a way no to give any quotes ?? Not single or double quotes. The reason I want that is I so that I can store objects in a column with key-value pairs and they are in {"key ": "value"}. I tried quotes: '' doesn't help as the output is '{key:value}'. If I don't pass the quotes option, I get this "{key:value}". Is there any way to disable any sort of quotes and have no quotes
Ok. this is how I handled it. give doubleQuotes first and then give quotes. var result = json2csv({ data: jsonMessages, fields: fields, doubleQuotes:'"', quotes: '', del: '\t' });
I just tried the example above with the latest code (not released yet):
And with quote: ''
I get:
car,price,color
Audi,40000,blue
BMW,35000,black
Porsche,60000,green
and without it I get:
"car","price","color"
"Audi",40000,"blue"
"BMW",35000,"black"
"Porsche",60000,"green"
Is that correct? Is there anything I'm missing here?
I'll close this for a lack of answer.
Feel free to reopen if you still think that is an issue.
Hello,
just noticed that the created csv has some problems with "".
Current code (working perfect!!)
CSV after fs.writefile and download it: Projekt,Start,Stop Projekt,15.06.2016, 13:42,15.06.2016, 13:43 Projekt2,15.06.2016, 13:45,15.06.2016, 13:45 Projekt3,15.06.2016, 13:46,15.06.2016, 14:14 Projekt4,15.06.2016, 14:55,15.06.2016, 14:57 Projekt5,16.06.2016, 10:48,16.06.2016, 10:48
If I remove quotes: ' ' in options (so default will be double quotes") my output will look like this Projekt,"Start","Stop" Projekt,15.06.2016, 13:42,15.06.2016, 13:43 Projekt2,15.06.2016, 13:45,15.06.2016, 13:45 Projekt3,15.06.2016, 13:46,15.06.2016, 14:14 Projekt4,15.06.2016, 14:55,15.06.2016, 14:57 Projekt5,16.06.2016, 10:48,16.06.2016, 10:48
Problem might be here, in the output of
There is a starting "double" double quotes csv = ""Projekt","Start","Stop" "Projekt","15.06.2016, 13:42","15.06.2016, 13:43" "Projekt2","15.06.2016, 13:45","15.06.2016, 13:45" "Projekt3","15.06.2016, 13:46","15.06.2016, 14:14" "Projekt4","15.06.2016, 14:55","15.06.2016, 14:57" "Projekt5","16....
No problem, as I can use the "quotes" parameter in options which helps.. just want to let you know
Thanks for this tool Bene