A light & simple parser of csv text


Keywords
csv, parser
License
MIT
Install
npm install naivecsv@0.0.33

Documentation

naivecsv

A light and simple csv parser.

Downloads Version License

Highlights

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

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: '\r\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 (c) 2019-present, Haoyang (Vincent) Wang