Comparing version 1.0.4 to 1.0.5
@@ -14,3 +14,6 @@ const commandLineArgs = require('command-line-args') | ||
console.error('csvfmt', require(require('path').join(__dirname, 'package.json')).version) | ||
console.error('Usage at: https://github.com/pokle/csvfmt') | ||
// console.error('Usage at: https://github.com/pokle/csvfmt') | ||
const fs = require('fs') | ||
const path = require('path') | ||
console.error(String(fs.readFileSync(path.join(__dirname, 'README.md')))); | ||
process.exit(0); | ||
@@ -17,0 +20,0 @@ } |
{ | ||
"name": "csvfmt", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "bin": "./index.js", |
@@ -8,6 +8,5 @@ # csvfmt | ||
This is a command line tool, so install it globally so it's available on your path: | ||
```shell | ||
npm install --global csvfmt | ||
``` | ||
npm install --global csvfmt | ||
## Specifying files | ||
@@ -17,9 +16,7 @@ | ||
```shell | ||
$ csvfmt samples/people.csv | ||
["name","sex","age"] | ||
["morris","m","12"] | ||
["jenna","f","13"] | ||
["yarris","c","200"] | ||
``` | ||
$ csvfmt samples/people.csv | ||
["name","sex","age"] | ||
["morris","m","12"] | ||
["jenna","f","13"] | ||
["yarris","c","200"] | ||
@@ -32,45 +29,34 @@ csvfmt reads CSV files from its standard input stream if no files are specified. | ||
```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"} | ||
...which makes it quite handy with jq: | ||
```shell | ||
$ csvfmt samples/people.csv --headers | jq 'select(.age | tonumber < 100)' | ||
{ | ||
"name": "morris", | ||
"sex": "m", | ||
"age": "12" | ||
} | ||
{ | ||
"name": "jenna", | ||
"sex": "f", | ||
"age": "13" | ||
} | ||
``` | ||
$ csvfmt samples/people.csv --headers | jq 'select(.age | tonumber < 100)' | ||
{ | ||
"name": "morris", | ||
"sex": "m", | ||
"age": "12" | ||
} | ||
{ | ||
"name": "jenna", | ||
"sex": "f", | ||
"age": "13" | ||
} | ||
--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 | ||
``` | ||
$ 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 | ||
``` | ||
## Development | ||
- `npm install -g` in this dir to install the dev version globally (symlinks!) | ||
- Bump up the version and release with `npm publish` | ||
$ csvfmt samples/people.csv --format '%2$s %1$s' | ||
sex name | ||
m morris | ||
f jenna | ||
c yarris |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
7161
9
34
60
3