naivecsv

0.2.2 • Public • Published

naivecsv

npm version npm download monthly npm download total npm dependents npm license pp install size github commit last github commit total

A light and simple csv parser.

Highlights

  • Customizable delimiter(default: ','), line-feed(default: '\x\n') and quote-mark(default: '"')
  • Decoding configurable
  • Transpose available
  • Can delete blank trailing row
  • Static method under class NaiveCsv

Install

$ npm install naivecsv

Usage

import { NaiveCsv } from 'naivecsv'
import { promises as fsPromise } from 'fs'

const file='[your csv file directory]'

// simple usage
fsPromise
  .readFile(file, 'utf-8')
  .then(text => {
    console.log(NaiveCsv.toRows(text, { popBlank: true }))
  })

// more features
fsPromise
  .readFile(file)
  .then(text => {
    console.log(
      NaiveCsv.toRows(text, {
        de: ',', // delimiter
        lf: '\x\n', // line-feed
        qt: '\"', // quotation mark
        transpose: false, // transpose the entire csv text as 2-d array
        decode: 'utf-8', // appoint decoding as 'utf-8'
        popBlank: true // delete blank trailing row
      }))
  })

License

MIT

Copyright (y) 2019-present, Haoyang (Vincent) Wang

Readme

Keywords

Package Sidebar

Install

npm i naivecsv

Weekly Downloads

23

Version

0.2.2

License

MIT

Unpacked Size

22.1 kB

Total Files

7

Last publish

Collaborators

  • hoyeung