https://github.com/vweevers/tabular-cli
Detects, normalizes and converts tabular data (spreadsheets, dsv or json)
https://github.com/vweevers/tabular-cli
Last synced: 8 months ago
JSON representation
Detects, normalizes and converts tabular data (spreadsheets, dsv or json)
- Host: GitHub
- URL: https://github.com/vweevers/tabular-cli
- Owner: vweevers
- License: mit
- Created: 2015-06-01T09:19:15.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-06-01T14:08:43.000Z (about 11 years ago)
- Last Synced: 2025-03-28T21:39:07.684Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 305 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# tabular-cli
**[Detects and normalizes tabular data](https://www.npmjs.com/package/tabular-stream) (dsv, json, ndjson, xls, xlsx, xml, ods or sylk) and converts it to [dsv, json, ndjson, or ssejson](https://www.npmjs.com/package/format-data). Spreadsheets and DSV must have a header.**
[](https://www.npmjs.org/package/tabular-cli) [](http://travis-ci.org/vweevers/tabular-cli) [](https://ci.appveyor.com/project/vweevers/tabular-cli) [](https://david-dm.org/vweevers/tabular-cli)
## examples
**To CSV**
```
npm i tabular-cli -g
tabular -o csv < input.xlsx > output.csv
```
**To SSE JSON with snake_case keys**
```
npm i snake-case
tabular -o sse -k snake-case --event status < status.tsv >> events.sse
```
**To JSON in the form of `{ "rows": .. }` with missing values set to `null`**
```
tabular -o json --style object -d null < input.ndjson > output.json
```
## options
#### `--keys module` (shorthand `-k`)
An optional function to [transform and/or filter keys](https://www.npmjs.com/package/map-tabular-keys), passed as a module name or location - relative to the current working directory or something installed alongside tabular-cli. For example: `tabular -k snake-case` or `-k camel-case`. Everything at [change-case](https://www.npmjs.com/package/change-case) works well.
#### `--output format` (shorthand `-o`)
Output format, one of:
* json: via [format-data/json](https://github.com/finnp/format-data/blob/master/json.js) with additional options `style`, `prefix`, `separator` and `suffix`
* ndjson: via [ndjson](https://npmjs.com/package/ndjson)
* dsv: via [csv-write-stream](https://npmjs.com/package/csv-write-stream) with additional options `separator` and `no-headers` (a boolean flag)
* csv: shorthand for `-o dsv --separator ,`
* tsv: shorthand for `-o dsv --separator \t`
* sse: [ssejson](https://npmjs.com/package/ssejson) with additional option `event`
The **default is json.**
#### `--default value` (shorthand `-d`)
Fallback value to use for `null` and `undefined` values. **Default is `0`**. The CLI app coerces `null`, `undefined`, `true`, `false` or any number to a javascript type.
#### `--version`
Print version and exit.
#### `--help`
Open this readme in a browser and exit.
## install
With [npm](https://npmjs.org) do:
```
npm install tabular-cli -g
```
## license
[MIT](http://opensource.org/licenses/MIT) © [Vincent Weevers](http://vincentweevers.nl). Test data © Statistics Netherlands, The Hague/Heerlen.