CSV wrangler to transform CSV into JSON object optimized for display in webapps, or JSON object of arrays optimized for interaction with a python/pandas/scikit/tensorflow backend via HTTP requests.
Traditional JavaScript
const fs = require("fs");
const wrangle = require("wrangle-csv");
const csvFile = fs.readFile("c:/path/to/your/file.csv");
const jsonArray = wrangle.csvToJsonArr(csvFile);
const jsonObject = wrangle.csvToJsonObj(csvFile);
Typescript
import * as fs from "fs";
import { csvToJsonArr, csvToJsonObj } from "wrangle-csv";
const csvFile = fs.readFile("c:/path/to/your/file.csv");
const jsonArray = csvToJsonArr(csvFile);
const jsonObject = csvToJsonObj(csvFile);
Assumes the following structure: 1st row = headers 1st column = label/indexing
csvToJsonArr(file, sep, newLine)
- file: accepts string
- sep (separator): default
,
- newLine: default
/n
Returns a JSON object with each row arranged as an array
csvToJsonObj(file, sep, newLine)
- file: accepts string
- sep (separator): default
,
- newLine: default
/n
Returns a JSON object
- Error handling
- Remove duplication and refactor