Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const path = require('path');
- const fs = require('fs');
- //joining path of directory
- const directoryPath = path.join(__dirname, 'Sales_Rep_Files');
- //passing directoryPath and callback function
- fs.readdir(directoryPath, (err, files) => {
- //handling error
- let Rep;
- if (err) throw err;
- console.log(files);
- //read file for the rep-info json file
- fs.readFile('Rep-Info.json' ,(err,data) => {
- if (err) throw err;
- Rep = JSON.parse(data);
- console.log(Rep);
- });
- // append the json file
- fs.appendFile("./final-result.json", JSON.stringify(files, null, 4),(err) => {
- if(err) throw err;
- console.log(err);
- })
- });
- // attempt to compare the csv file to the json file.
- // long way would be to write a very long array.
- // let arr = [{
- // id: 'Jeff_May_5807757.csv',
- // name: 'rev.jeffmay@gmail.com'
- // }, {
- // id:'' ,
- // name: ''
- // }]
- // let result = arr.map(person => ({ value: person.id, text: person.name }));
- // console.log(result)
- // })
Add Comment
Please, Sign In to add comment