Skip to content

Instantly share code, notes, and snippets.

View pilgreen's full-sized avatar

Jay Pilgreen pilgreen

View GitHub Profile
@pilgreen
pilgreen / csvToJSON.js
Created February 25, 2020 21:31
Simple lightweight CSV conversion to JSON.
function csvToJSON(csv) {
const lines = csv.split('\n')
const result = []
const headers = lines[0].split(',')
for (let i = 1; i < lines.length; i++) {
if (!lines[i])
continue
const obj = {}
const currentline = lines[i].split(',')