我在使用json2csv节点模块(https://www.npmjs.com/package/json2csv)时遇到问题。这是我的代码:
var fields = ['originCountry', 'destinationCountry', 'avgNationalTuitionFee'];
var outputResult = [
{
"outputOriginCountry" : "Denmakr", //origin,
"outputDestinationCountry" : "Germany", //destination,
"outputAvgTuitionFee" : "10000"
},
{
"outputOriginCountry" : "Italy", //origin,
"outputDestinationCountry" : "Spain", //destination,
"outputAvgTuitionFee" : "5000"
}
];
var csv = json2csv({ data: outputResult, fields: fields });
console.log("Csv file contains " + csv)
fs.writeFile('analysis-output.csv', csv, function(err) {
if (err) throw err;
console.log('file saved');
});
但是,我不知道问题是什么。你有任何线索吗?
非常感谢!