Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const csvToJson = csv => {
- const [firstLine, ...lines] = csv.split('\n');
- return lines.map(line =>
- firstLine.split(',').reduce(
- (curr, next, index) => ({
- ...curr,
- [next]: line.split(',')[index],
- }),
- {}
- )
- );
- };
Add Comment
Please, Sign In to add comment