Created
April 24, 2020 23:38
-
-
Save edermanoel94/7aec4f39c2aac6e9e404321017c5e953 to your computer and use it in GitHub Desktop.
Helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const csv = require('fast-csv'); | |
fs.createReadStream('file.json') | |
.pipe(csv.parse({headers: false})) | |
.on('data', row => { | |
readRow(row) | |
.then((obj) => { | |
console.log(obj) | |
// axios aqui | |
}) | |
.catch((err) => { | |
console.log(err) | |
}) | |
}); | |
const readRow = (row) => { | |
return new Promise((resolve, reject) => { | |
try { | |
resolve(JSON.parse(row)) | |
} catch (e) { | |
reject(e) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment