Created
January 27, 2016 19:24
-
-
Save natasv/8d8046a7b4d7e993ddec 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.readFileSystem('example.txt', 'utf8') | |
.trim() | |
.split('\n') | |
.map(line => line.split('\t')) | |
.reduce((customers, line) => { | |
customers[line[0]] = customers[line[0]] || [] | |
customers[line[0]].push({ | |
name: line[1], | |
smth: line[2] | |
}); | |
return customers; | |
},{}); | |
/* | |
* Data example: | |
* mark name smth | |
* mark name smth | |
* mark name smth | |
* jhon name smth | |
* jhon name smth | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment