I'm using this json2scv package parsing my data (sample json data is described in below code)
I am trying to generate a CSV file in my nodejs application using the code below:
If I open the file in Excel, then I get £
wherever a £
sign should appear.
var json2csv = require('json2csv');
var fs = require('fs');
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"
}
];
var csvStr = json2csv({ data: myCars, fields: fields, del: ',' });
fs.writeFile('file.csv', csvStr, { encoding: 'utf8' },function(err) {
if (err) throw err;
console.log('file saved');
});
Any Thoughts ?
Thanks.