neekey / table-parser

A parser to parse table style output from shell
MIT License
25 stars 13 forks source link

Table parser omitting a column and adding the value in another column #1

Closed jviotti closed 8 years ago

jviotti commented 9 years ago

I'm having a small issue with the following input from lsblk:

$ lsblk -d --output NAME,MODEL,SIZE
NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb    8:16   1  14.9G  0 disk

If I parse it with table-parser, there is no RM property, and the RM value gets added to MAJ:MIN instead:

tableParser = require('table-parser')

input = '''
    NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
    sdb    8:16   1  14.9G  0 disk
'''

parsedData = tableParser.parse(input)
console.log(parsedData)

[ { NAME: [ 'sdb' ],
    'MAJ:MIN': [ '8:16', '1' ],
    SIZE: [ '14.9G' ],
    RO: [ '0' ],
    TYPE: [ 'disk' ] } ]
IstoraMandiri commented 8 years ago

I think this is the same issue as https://github.com/neekey/table-parser/pull/3

The logic for calculating which header lines up with the value is flawed at the moment

neekey commented 8 years ago

@jviotti 0.1.0 should fix this, sorry for the long wait.