Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const csv = require('csvtojson')
- const fs = require('fs')
- csv()
- .fromFile('./StudentsPerformance.csv')
- .then(array => {
- return array.map((value, i) => {
- const val =
- parseInt(
- (Number(value['math score']) +
- Number(value['reading score']) +
- Number(value['writing score'])) /
- 3
- ) >= 60
- ? true
- : false
- return { ...value, 'is approved': val }
- })
- })
- .then(data =>
- fs.writeFile(
- './StudentsPerformance.json',
- JSON.stringify(data),
- (err, data) => {
- if (err) console.log(err)
- else console.log('done!')
- }
- )
- )
Add Comment
Please, Sign In to add comment