Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Write to a CSV in Node.js

Write to a CSV in Node.js

Problem

I am struggling to find a way to write data to a CSV in Node.js.

There are several CSV plugins available however they only 'write' to Stdout. Ideally I want to Write on a row-by-row basis using a loop.

Thanks in advance.

Problem courtesy of: Phil Bottomley

Solution

The docs for node-csv-parser (npm install csv) specifically state that it can be used with streams (see fromStream, toStream). So it's not hard-coded to use stdout.

Several other CSV parsers also come up when you npm search csv -- you might want to look at them too.

Solution courtesy of: Joe White

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Write to a CSV in Node.js

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×