Created
March 7, 2019 15:57
-
-
Save Meandmybadself/fbc09e1bf9ede1911566aa56a17958fd to your computer and use it in GitHub Desktop.
Merge csvs
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 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