Have ideas to improve npm?Join in the discussion! »

naivecsv

0.2.0 • 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

Keywords

Install

npm i naivecsv

DownloadsWeekly Downloads

38

Version

0.2.0

License

MIT

Unpacked Size

13.3 kB

Total Files

5

Last publish

Collaborators

  • avatar