Answers for "nodejs csv to json from link"

2

nodejs csv to json from link

// npm install --save csvtojson@latest
const csv = require("csvtojson");
const request = require('request');
// Convert a csv file with csvtojson
csv().fromStream(request.get('https://fileas.csv))
  	.then(function(jsonArrayObj){
  		//when parse finished, result will be emitted here.
    	console.log(jsonArrayObj); 
 	})
Posted by: Guest on July-22-2021
0

json to csv nodejs

const { Parser } = require('json2csv');

const myCars = [
  {
    "car": "Audi",
    "price": 40000,
    "color": "blue"
  }, {
    "car": "BMW",
    "price": 35000,
    "color": "black"
  }, {
    "car": "Porsche",
    "price": 60000,
    "color": "green"
  }
];

const json2csvParser = new Parser();
const csv = json2csvParser.parse(myCars);

console.log(csv);
Posted by: Guest on June-28-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language