Created
October 7, 2019 17:41
-
-
Save AndresMWeber/ebb437bf2c408a81cb8b1fb4cfa41471 to your computer and use it in GitHub Desktop.
Convert CSV to JSON Example
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
/** | |
* This is meant to be run on data.csv coming in from Talal. It only converts to JSON and hardcodes the filepath. | |
*/ | |
function convertCSVtoJSON() { | |
csv() | |
.fromFile('data.csv') | |
.then((crimeDataSet) => { | |
fs.writeFile("data.json", JSON.stringify(crimeDataSet), 'utf8', function(err) { | |
if (err) { | |
console.log("An error occurred while writing JSON Object to File."); | |
return console.log(err); | |
} | |
console.log("JSON file has been saved."); | |
}); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment