Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

csvfmt

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csvfmt - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

sprintf.js

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc