1// npm install --save csvtojson@latest
2const csv = require("csvtojson");
3const request = require('request');
4// Convert a csv file with csvtojson
5csv().fromStream(request.get('https://fileas.csv))
6 .then(function(jsonArrayObj){
7 //when parse finished, result will be emitted here.
8 console.log(jsonArrayObj);
9 })
1const { Parser } = require('json2csv');
2
3const myCars = [
4 {
5 "car": "Audi",
6 "price": 40000,
7 "color": "blue"
8 }, {
9 "car": "BMW",
10 "price": 35000,
11 "color": "black"
12 }, {
13 "car": "Porsche",
14 "price": 60000,
15 "color": "green"
16 }
17];
18
19const json2csvParser = new Parser();
20const csv = json2csvParser.parse(myCars);
21
22console.log(csv);