# table-parser

> Simple parser for shell-style data output

Latest version **1.0.1** (published 2018-04-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install table-parser
pnpm add table-parser
yarn add table-parser
bun add table-parser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-04-07 |
| First published | 2013-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 264.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Neekey ni184775761@gmail.com |
| Maintainers | neekey |
| Keywords | table parser shell |

## Links

- npm: https://www.npmjs.com/package/table-parser
- Repository: https://github.com/neekey/table-parser
- Homepage: https://github.com/neekey/table-parser#readme
- Issues: https://github.com/neekey/table-parser/issues
- npm.io page: https://npm.io/package/table-parser

## Dependencies (2)

- [connected-domain](https://npm.io/package/connected-domain.md) ^1.0.0
- [@semantic-release/git](https://npm.io/package/@semantic-release/git.md) ^4.0.1

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2018-04-07
- 1.0.0 — 2018-04-07
- 0.1.3 — 2016-10-18
- 0.1.2 — 2016-10-16
- 0.1.1 — 2016-05-05
- 0.1.0 — 2016-04-26
- 0.0.3 — 2013-01-28
- 0.0.2 — 2013-01-28
- 0.0.1 — 2013-01-27

## README

TableParser [![Build Status](https://travis-ci.org/neekey/table-parser.svg)](https://travis-ci.org/neekey/table-parser)
================

A parser to parse table style output from shell

## Install

```
npm install table-parser
```

## Usage

We have some kind of log below as `test/ps.log`:

```bash
  PID TTY           TIME CMD
49692 ttys000    0:00.06 login -pfl neekey /bin/bash -c exec -la bash /bin/bash
49693 ttys000    0:00.06 -bash
54195 ttys000    0:00.09 node run

...

56266 ttys005    0:00.06 login -pfl neekey /bin/bash -c exec -la bash /bin/bash
56269 ttys005    0:00.04 -bash
56463 ttys005    0:00.09 node test.js
56464 ttys005    0:00.01 ps -a
```

Use table-parser to parse it into object:

```
var FS = require( 'fs' );
var Parser = require('table-parser');

var linux_ps = './ps.log';

data = FS.readFileSync( linux_ps ).toString();
var parsedData = Parser.parse( data );

console.log( parsedData );

```

Which will output:

```bash
[ { PID: [ '49692' ],
    TTY: [ 'ttys000' ],
    TIME: [ '0:00.06' ],
    CMD:
     [ 'login',
       '-pfl',
       'neekey',
       '/bin/bash',
       '-c',
       'exec',
       '-la',
       'bash',
       '/bin/bash' ] },
  ...

  { PID: [ '56464' ],
    TTY: [ 'ttys005' ],
    TIME: [ '0:00.01' ],
    CMD: [ 'ps', '-a' ] } ]
```

## Double quotation marks

Normally, all the values will be transformed into array using `split( /\s+/ )`, but string wrapped with `"` will be treated as a continuous string. 

For example, the CommandLine below:

```
"C:\Program Files\Internet Explorer\iexplore.exe" --name="Jack Neekey" --sex=male otherargs
```

will be split into:

- `C:\Program Files\Internet Explorer\iexplore.exe` ( `"` will be removed, if `"` is at the beginning )
- `--name="Jack Neekey"`    ( `"` is reserved )
- `--sex=male`
- `otherargs`

---
_Source: https://npm.io/package/table-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
