csv-write-stream
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -24,2 +24,2 @@ var csv = require('./') | ||
for (var i = 0; i < 2000000; i++) c.write(obj) | ||
c.end() | ||
c.end() |
34
cli.js
#!/usr/bin/env node | ||
var ArgumentParser = require('argparse').ArgumentParser | ||
var csv = require('./') | ||
var fs = require('fs') | ||
var minimist = require('minimist') | ||
var ndj = require('ndjson') | ||
var packageInfo = require('./package') | ||
var args = minimist(process.argv.slice(2)) | ||
argparser = new ArgumentParser({ | ||
addHelp: true, | ||
description: packageInfo.description + ' JSON is read from STDIN, formatted' + | ||
' to CSV, and written to STDOUT.', | ||
version: packageInfo.version | ||
}) | ||
argparser.addArgument(['--separator'], { | ||
help: "The separator character to use. Defaults to ','.", | ||
defaultValue: ',' | ||
}) | ||
argparser.addArgument(['--newline'], { | ||
help: "The newline character to use. Defaults to $'\\n'.", | ||
defaultValue: '\n' | ||
}) | ||
argparser.addArgument(['--headers'], { | ||
nargs: '+', | ||
help: 'The list of headers to use. If omitted, the keys of the first row ' + | ||
'written to STDIN will be used', | ||
}) | ||
argparser.addArgument(['--no-send-headers'], { | ||
action: 'storeFalse', | ||
help: "Don't print the header row.", | ||
defaultValue: true, | ||
dest: 'sendHeaders' | ||
}) | ||
args = argparser.parseArgs() | ||
process.stdin | ||
.pipe(ndj.parse()) | ||
.pipe(csv(args)) | ||
.pipe(process.stdout) | ||
.pipe(process.stdout) |
@@ -8,2 +8,3 @@ ## Collaborators | ||
<tr><th align="left">finnp</th><td><a href="https://github.com/finnp">GitHub/finnp</a></td></tr> | ||
<tr><th align="left">slang800</th><td><a href="https://github.com/slang800">GitHub/slang800</a></td></tr> | ||
</tbody></table> |
@@ -99,2 +99,2 @@ var stream = require('stream') | ||
return '"'+cell.replace(/"/g, '""')+'"' | ||
} | ||
} |
{ | ||
"name": "csv-write-stream", | ||
"version": "1.0.0", | ||
"description": "A CSV encoder stream that produces properly escaped CSVs", | ||
"main": "index.js", | ||
"bin": "cli.js", | ||
"scripts": { | ||
"test": "node test.js" | ||
"description": "A CSV encoder stream that produces properly escaped CSVs.", | ||
"version": "2.0.0", | ||
"author": "max ogden", | ||
"bin": { | ||
"csv-write": "cli.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:maxogden/csv-write-stream.git" | ||
"bugs": { | ||
"url": "https://github.com/maxogden/csv-write-stream/issues" | ||
}, | ||
"author": "max ogden", | ||
"license": "BSD", | ||
"dependencies": { | ||
"argparse": "^1.0.7", | ||
"generate-object-property": "^1.0.0", | ||
"minimist": "^1.1.0", | ||
"ndjson": "^1.3.0" | ||
}, | ||
"devDependencies": { | ||
"tape": "~2.3.2", | ||
"concat-stream": "~1.4.1" | ||
"concat-stream": "~1.4.1", | ||
"tape": "~2.3.2" | ||
}, | ||
"homepage": "https://github.com/maxogden/csv-write-stream", | ||
"license": "BSD-2-Clause", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:maxogden/csv-write-stream.git" | ||
}, | ||
"scripts": { | ||
"test": "node test.js" | ||
}, | ||
"testling": { | ||
@@ -40,7 +46,3 @@ "files": "test.js", | ||
] | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/maxogden/csv-write-stream/issues" | ||
}, | ||
"homepage": "https://github.com/maxogden/csv-write-stream" | ||
} | ||
} |
@@ -11,7 +11,7 @@ # csv-write-stream | ||
### usage | ||
## usage | ||
##### var writer = csvWriter([options]) | ||
### var writer = csvWriter([options]) | ||
```js | ||
```javascript | ||
var csvWriter = require('csv-write-stream') | ||
@@ -23,5 +23,5 @@ var writer = csvWriter() | ||
#### default options | ||
### default options | ||
```js | ||
```javascript | ||
{ | ||
@@ -39,4 +39,4 @@ separator: ',', | ||
```js | ||
var writer = csv() | ||
```javascript | ||
var writer = csvWriter() | ||
writer.pipe(fs.createWriteStream('out.csv')) | ||
@@ -51,4 +51,4 @@ writer.write({hello: "world", foo: "bar", baz: "taco"}) | ||
```js | ||
var writer = csv({ headers: ["hello", "foo"]}) | ||
```javascript | ||
var writer = csvWriter({ headers: ["hello", "foo"]}) | ||
writer.pipe(fs.createWriteStream('out.csv')) | ||
@@ -63,4 +63,4 @@ writer.write(['world', 'bar']) | ||
```js | ||
var writer = csv({sendHeaders: false}) | ||
```javascript | ||
var writer = csvWriter({sendHeaders: false}) | ||
writer.pipe(fs.createWriteStream('out.csv')) | ||
@@ -75,3 +75,3 @@ writer.write({hello: "world", foo: "bar", baz: "taco"}) | ||
### run the test suite | ||
## run the test suite | ||
@@ -83,10 +83,29 @@ ```bash | ||
### cli usage | ||
## cli usage | ||
This module also includes a CLI, which you can pipe [ndjson](http://ndjson.org) | ||
to stdin and it will print csv on stdout. You can install it with | ||
`npm install -g csv-write-stream`. | ||
This module also includes a CLI, which you can pipe [ndjson](http://ndjson.org) to stdin and it will print csv on stdout. You can install it with `npm install -g csv-write-stream`. | ||
```bash | ||
$ csv-write --help | ||
usage: csv-write [-h] [-v] [--separator SEPARATOR] [--newline NEWLINE] | ||
[--headers HEADERS [HEADERS ...]] [--no-send-headers] | ||
A CSV encoder stream that produces properly escaped CSVs. JSON is read from | ||
STDIN, formatted to CSV, and written to STDOUT. | ||
Optional arguments: | ||
-h, --help Show this help message and exit. | ||
-v, --version Show program's version number and exit. | ||
--separator SEPARATOR | ||
The separator character to use. Defaults to ','. | ||
--newline NEWLINE The newline character to use. Defaults to $'\n'. | ||
--headers HEADERS [HEADERS ...] | ||
The list of headers to use. If omitted, the keys of | ||
the first row written to STDIN will be used | ||
--no-send-headers Don't print the header row. | ||
``` | ||
cat example.ndjson | csv-write-stream > example.csv | ||
```bash | ||
$ cat example.ndjson | csv-write > example.csv | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
13995
0
258
105
0
1
+ Addedargparse@^1.0.7
+ Addedargparse@1.0.10(transitive)
+ Addedsprintf-js@1.0.3(transitive)
- Removedminimist@^1.1.0