write-csv
Version:
Quickly write json array to a .csv file
46 lines (32 loc) • 986 B
Markdown
# write-csv
[](https://www.npmjs.com/package/write-csv)
[](https://travis-ci.org/dsernst/write-csv)
[](https://coveralls.io/github/dsernst/write-csv?branch=master)
### Quickest way to write a json array to a .csv file
## Install
Install with npm:
```
npm i --save write-csv
```
Then require in your file:
```js
var writeCSV = require('write-csv')
```
## Usage
### writeFile(filename, data)
- `filename` String filename or file descriptor
- `data` Array of objects
```js
writeCSV('./results.csv', [
{a: 'foo', b: 'bar', c: 'baz'},
{a: 'shoo', b: 'boo', c: 'chaz'},
{a: 'gaia', b: 'loves', c: 'you'},
])
```
This will synchronously write your data to `results.csv` like this:
```csv
a,b,c
foo,bar,baz
shoo,boo,chaz
gaia,loves,you
```