json2csv nodejs using newline delimiter

My JSON object is newline delimited and looks something like this:

    {"car": {"make": "Audi", "model": "A3"}, "price": 4000,"color": "blue"}
    {"car": {"make": "BMW", "model": "F20"},"price": 35000,"color": "black"}
    {"car": {"make": "Porsche", "model": "9PA AF1"},"price": 60000,"color": "green"}

EDIT: I need node to read in a newline from the JSON file. Not output a newline. it's an extremely large JSON file where each object is delimited by a newline as opposed to a ','


It doesn't look like you need the delimiter field. Try

json2csv({ data: myCars, fields: fields }, function(err, csv) { ... }

Example from the docs : https://github.com/zemirco/json2csv

var json2csv = require('json2csv');
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"

json2csv({ data: myCars, fields: fields }, function(err, csv) {
  if (err) console.log(err);
  fs.writeFile('file.csv', csv, function(err) {
    if (err) throw err;
    console.log('file saved');

creates output file :

car, price, color
"Audi", 40000, "blue"
"BMW", 35000, "black"
"Porsche", 60000, "green"

Need Your Help

why does my tableview not call didselectrowatindexpath until 2nd touch?

ios objective-c uitableview popviewcontrolleranimated

I have a parent table view with custom rows, each one pushes a view controller with a tableview of selectable options that are stored as properties of the parent view controller. My code:

Why does Meteor update a record without running a "Meteor.call" to update?

javascript angularjs meteor

I am working on a Meteor.js app and I've gotten a hang of Meteor per se, but maybe I'm misunderstanding something about its principle of reactivity or haven't read about it enough.