Skip to content

Instantly share code, notes, and snippets.

@nunull
Created September 14, 2016 20:15
Show Gist options
  • Save nunull/52f303c8e12e0fe835f42dbbe890805a to your computer and use it in GitHub Desktop.
Save nunull/52f303c8e12e0fe835f42dbbe890805a to your computer and use it in GitHub Desktop.
Reduce Advanced - Using ramda.js
import fs from 'fs'
import { map, compose, split, trim, groupBy, head } from 'ramda'
const parseList = compose(
map(map(([_, name, price, quantity]) => ({ name, price, quantity }))),
groupBy(head),
map(split('\t')),
split('\n'),
trim
)
console.log(parseList(fs.readFileSync('test-list.csv', 'utf8')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment