Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Merge csvs
const csv = require('csvtojson')
const _ = require('lodash')
const Json2csvParser = require('json2csv').Parser
;(async () => {
const points = await csv().fromFile('./points.csv')
let data = await csv().fromFile('./data.csv')
data = data.map(row => {
const username = row.Username
const pointsRow = _.find(points, { username })
if (pointsRow) {
delete pointsRow.username
return { ...row, ...pointsRow }
} else {
console.log(username)
}
})
console.log(JSON.stringify(data, null))
//console.log(data[0])
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment