Guest User

Untitled

a guest
Apr 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. const csvToJson = csv => {
  2. const [firstLine, ...lines] = csv.split('\n');
  3. return lines.map(line =>
  4. firstLine.split(',').reduce(
  5. (curr, next, index) => ({
  6. ...curr,
  7. [next]: line.split(',')[index],
  8. }),
  9. {}
  10. )
  11. );
  12. };
Add Comment
Please, Sign In to add comment