Skip to content

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.

License

NeonSpork/wrangle-csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npmCodacy BadgeMaintainability

wrangle-csv

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.

Example imports:

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);

Methods

Assumes the following structure: 1st row = headers 1st column = label/indexing

CSV to JSON structured as arrays

csvToJsonArr(file, sep, newLine)

  • file: accepts string
  • sep (separator): default ,
  • newLine: default /n Returns a JSON object with each row arranged as an array

CSV to JSON object

csvToJsonObj(file, sep, newLine)

  • file: accepts string
  • sep (separator): default ,
  • newLine: default /n Returns a JSON object

TODO

  • Error handling
  • Remove duplication and refactor

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published