Created
October 30, 2015 10:20
-
-
Save zlargon/a469532965874e11a66c to your computer and use it in GitHub Desktop.
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
import fs from 'fs' | |
var output = fs.readFileSync('input.txt', 'utf8') | |
.trim() // remove end of line | |
.split('\n') | |
.map(line => line.split('\t')) | |
.reduce((customers, [ user, name, price, quality ]) => { | |
customers[user] = customers[user] || []; | |
customers[user].push({ name, price, quality }); | |
return customers; | |
}, {}); | |
console.log(JSON.stringify(output, null, 2)); |
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
mark johansson waffle iron 80 2 | |
mark johansson blender 200 1 | |
mark johansson knife 10 4 | |
Nikita Smith waffle iron 80 1 | |
Nikita Smith knife 10 2 | |
Nikita Smith pot 20 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment