Last active
September 14, 2018 11:03
-
-
Save sorsaffari/aa3952915f08421549cd88b7ced772e1 to your computer and use it in GitHub Desktop.
Phone Calls | Loading Data: parsing CSV
This file contains hidden or 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
function parseDataToObjects(input) { | |
const items = []; | |
return new Promise(function(resolve, reject) { | |
papa.parse( | |
fs.createReadStream(input.dataPath + ".csv"), | |
{ | |
header: true, // a Papaparse config option | |
step: function(result, parser) { | |
items.push(result.data[0]); | |
}, | |
complete: function() { | |
resolve(items); | |
} | |
} | |
); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment