nodejs csv to json from link 1

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); 
 	})

Here is what the above code is Doing:
1. We’re using the csvtojson package to convert a csv file to json.
2. We’re using the request package to make a request to the url of the csv file.
3. We’re using the fromStream method to convert the csv file to json.
4. We’re using the then method to log the jsonArrayObj to the console.

Similar Posts