zemirco / json2csv

Convert json to csv with column titles
http://zemirco.github.io/json2csv
MIT License
2.71k stars 365 forks source link

How can I export as csv file?? #177

Closed zolfj closed 7 years ago

zolfj commented 7 years ago

Hello there,

I am using your library to generate csv for export and my code looks like so, var opts = { data: this.data, fields: fields, quotes: '', hasCSVColumnTitle: false }; json2csv(opts, function (err, csv) { if (err) console.log(err); console.log(csv); });`

How can I expor this to a csv file. Please help!!

knownasilya commented 7 years ago

The first example shows you how https://github.com/zemirco/json2csv#example-1

zolfj commented 7 years ago

Thanks for your comments. But when i try to use that fs.writefile and dalling this var fs = require('fs'); in my Angular 2 application, it complains about writeFile. Can you please guide me. I am using this in my angular 2 class.

knownasilya commented 7 years ago

This module is for node.js only (server side). Maybe try out http://papaparse.com/ with something like https://stackoverflow.com/a/14966131/483616