Skip to content

Instantly share code, notes, and snippets.

@natasv
Created January 27, 2016 19:24
Show Gist options
  • Save natasv/8d8046a7b4d7e993ddec to your computer and use it in GitHub Desktop.
Save natasv/8d8046a7b4d7e993ddec to your computer and use it in GitHub Desktop.
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