Giter VIP home page Giter VIP logo

csv2's Introduction

csv2

Build Status

NPM

A Node Streams2 CSV parser

Will parse an input character stream and pass on an array for each line of CSV data.

csv2 can handle basic CSV quoting and escaping: foo,"bar","wut? ""whoa!""","commas, in, my, strings??"

The only main "feature" not currently supported is newlines within quoted strings; newlines are treated strictly as row separators.

fs.createReadStream('data.csv')
  .pipe(csv2())
  .on('data', console.log)

Or, use through2 to transform your CSV into JSON:

fs.createReadStream('data.csv')
  .pipe(csv2())
  .pipe(through2({ objectMode: true }, function (chunk, enc, callback) {
    this.push({
        name    : chunk[0]
      , address : chunk[3]
      , phone   : chunk[10]
    })
    callback()
  }))
  .on('data', console.log)

API

csv2([ options ])

The optional options object is passed through to the stream.Through class. You can supply a 'separator' option to change the default separator from ',' to whatever your data is using.

License

csv2 is Copyright (c) 2013 Rod Vagg @rvagg and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.