CSVStringify for Node.js

IssuesGitHub

CSV Stringify examples

Introduction

This package proposes different API flavors. Every example is available on GitHub.

Using the pipe function

One useful function part of the Stream API is pipe. It is used to connect multiple stream.Readable sources to stream.Writable destinations.

The pipe example generates object records, stringifies them and print the generated CSV to the standard output.

import { stringify } from 'csv-stringify';
import { generate } from 'csv-generate';

generate({
  length: 20,
  objectMode: true,
  seed: 1,
  headers: 2,
  duration: 400
})
  .pipe(stringify({
    header: true,
    columns: {
      year: 'birthYear',
      phone: 'phone'
    }
  }))
  .pipe(process.stdout);

Run this example with the command node samples/api.pipe.js.

About

The Node.js CSV project is an open source product hosted on GitHub and developed by Adaltas.