Last active
June 5, 2019 13:32
-
-
Save AndersDJohnson/10743525 to your computer and use it in GitHub Desktop.
csvToJson
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
var csv = require('csv'); | |
csv() | |
.from.path(__dirname+'/export.csv', { delimiter: ',', escape: '"' }) | |
.to.array( function(data){ | |
var labels = data.shift(); | |
var items = []; | |
data.forEach(function (row) { | |
var item = {}; | |
row.forEach(function (value, index) { | |
var label = labels[index]; | |
item[label] = value; | |
}); | |
items.push(item); | |
}); | |
console.log(items); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment