Comparing version 1.0.1 to 1.0.2
16
index.js
#!/usr/bin/env node | ||
const options = require('./args'); | ||
const options = require("./args"); | ||
function print(data) { | ||
console.log(data); | ||
} | ||
const print = options.format | ||
? require("./sprintf")(options.format) | ||
: (data) => console.log(JSON.stringify(data)); | ||
@@ -12,7 +12,7 @@ const csv = require("fast-csv"); | ||
if (options.files.length === 0) { | ||
csv.fromStream(process.stdin, csvOptions).on('data', print) | ||
csv.fromStream(process.stdin, csvOptions).on("data", print); | ||
} else { | ||
for(let i=0; i<options.files.length; i++) { | ||
csv.fromPath(options.files[i], csvOptions).on('data', print) | ||
} | ||
for (let i = 0; i < options.files.length; i++) { | ||
csv.fromPath(options.files[i], csvOptions).on("data", print); | ||
} | ||
} |
{ | ||
"name": "csvfmt", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "index.js", | ||
@@ -10,4 +10,4 @@ "bin": "./index.js", | ||
"fast-csv": "^2.4.0", | ||
"gofmt": "^0.1.0" | ||
"sprintf-js": "^1.1.1" | ||
} | ||
} |
@@ -14,10 +14,10 @@ # csvfmt | ||
Provide files on the command line to parse: | ||
Provide files on the command line to parse. csvparse gives you a JSON representation of your CSV file (Useful with jq) | ||
``` | ||
```shell | ||
$ csvfmt samples/people.csv | ||
[ 'name', 'sex', 'age' ] | ||
[ 'morris', 'm', '12' ] | ||
[ 'jenna', 'f', '13' ] | ||
[ 'yarris', 'c', '200' ] | ||
["name","sex","age"] | ||
["morris","m","12"] | ||
["jenna","f","13"] | ||
["yarris","c","200"] | ||
``` | ||
@@ -31,7 +31,25 @@ | ||
```shell | ||
$ csvfmt --headers samples/people.csv | ||
{"name":"morris","sex":"m","age":"12"} | ||
{"name":"jenna","sex":"f","age":"13"} | ||
{"name":"yarris","sex":"c","age":"200"} | ||
``` | ||
$ csvfmt --headers samples/people.csv | ||
{ name: 'morris', sex: 'm', age: '12' } | ||
{ name: 'jenna', sex: 'f', age: '13' } | ||
{ name: 'yarris', sex: 'c', age: '200' } | ||
--format lets you specify [sprintf](https://www.npmjs.com/package/sprintf-js) style formatting: | ||
```shell | ||
$ csvfmt samples/people.csv --headers --format '%(age)4d %(sex)s %(name)s' | ||
12 m morris | ||
13 f jenna | ||
200 c yarris | ||
``` | ||
You can also use positional indexes: | ||
```shell | ||
csvfmt samples/people.csv --format '%2$s %1$s' | ||
sex name | ||
m morris | ||
f jenna | ||
c yarris | ||
``` |
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
6439
8
29
53
+ Addedsprintf-js@^1.1.1
+ Addedsprintf-js@1.1.3(transitive)
- Removedgofmt@^0.1.0
- Removedfilesize@2.0.4(transitive)
- Removedgofmt@0.1.0(transitive)
- Removedprintable-string@0.3.0(transitive)