Socket
Socket
Sign inDemoInstall

dumb-csv

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dumb-csv

Unfancy and dumb Node.js csv to json or markdown converter


Version published
Weekly downloads
7
decreased by-75%
Maintainers
1
Install size
12.1 kB
Created
Weekly downloads
 

Changelog

Source

1.1.2

  • Fix float parsing causing conversion data loss (#8) (thanks @extremeheat)

Readme

Source

dumb-csv

NPM version Build Status Try it on gitpod

An unfancy CSV to JSON/markdown parsing lib with no streams or asynchrony

Install

npm install dumb-csv

Usage

const dumbcsv = require('dumb-csv')
dumbcsv
  .fromCSV({ data: 'hello,world', separator: ',', headerFields: ['a', 'b'] })
  .toJSON()
// [{"a":"hello","b":"world"}]

API

fromCSV(options: { data, file, separator = ',', headerFields, overrideExistingHeader, parseFloats = true }) : { toJSON: () => object, toMarkdown: () => string }

Input options object:

  • data (string) -- a string representing the CSV data
  • OR file (string) -- a path to the CSV
  • headerFields (optional string[]) -- an array of strings containing the headers for the CSV, assuming they are not the 1st line
  • overrideExistingHeader (optional bool) -- if the 1st line IS a header, but your headerFields should override it
  • parseFloats (default true) -- if we should try and convert rows that are numbers into JS Number's, or if false keep everything as strings

Output object :

  • toJSON() (function) -- calling this will return a javascript object that represents the CSV
  • toMarkdown() (function) -- calling this will return a string that has a formatted markdown table inside that represents the CSV

Keywords

FAQs

Last updated on 21 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc