Skip to content

Instantly share code, notes, and snippets.

@SuvamPrasd
Last active March 28, 2020 06:39
Show Gist options
  • Save SuvamPrasd/1e3c7e016531d21f3431b506acbf04d3 to your computer and use it in GitHub Desktop.
Save SuvamPrasd/1e3c7e016531d21f3431b506acbf04d3 to your computer and use it in GitHub Desktop.
const csvFilePath = 'customer-data.csv';
const uuidv1 = require('uuid/v1');
const fs = require('fs');
const path = require('path');
const csv = require('csvtojson');
csv().fromFile(csvFilePath).then((jsonObj)=>{
let buff = ''
let folderName = uuidv1();
fs.mkdirSync(folderName);
buff = JSON.stringify(jsonObj);
fs.writeFileSync(path.join(__dirname, folderName, 'resultJSON.json'), buff);
// console.log(jsonObj);
console.log('Coverting completed');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment