2022-01-25 17:07:47 -08:00
|
|
|
<a id="jc.parsers.universal"></a>
|
2022-01-20 09:46:24 -08:00
|
|
|
|
|
|
|
# jc.parsers.universal
|
2022-01-25 17:07:47 -08:00
|
|
|
|
2022-01-20 09:46:24 -08:00
|
|
|
jc - JSON CLI output utility universal Parsers
|
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
<a id="jc.parsers.universal.simple_table_parse"></a>
|
|
|
|
|
|
|
|
#### simple\_table\_parse
|
|
|
|
|
2022-01-20 09:46:24 -08:00
|
|
|
```python
|
2022-01-25 17:07:47 -08:00
|
|
|
def simple_table_parse(data)
|
2022-01-20 09:46:24 -08:00
|
|
|
```
|
|
|
|
|
2022-01-20 09:59:23 -08:00
|
|
|
Parse simple tables. The last column may contain data with spaces.
|
2022-01-20 09:46:24 -08:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
**Arguments**:
|
2022-01-20 09:46:24 -08:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
|
|
|
|
- `data` - (list) Text data to parse that has been split into lines
|
|
|
|
via .splitlines(). Item 0 must be the header row.
|
|
|
|
Any spaces in header names should be changed to
|
|
|
|
underscore '_'. You should also ensure headers are
|
|
|
|
lowercase by using .lower().
|
|
|
|
|
|
|
|
Also, ensure there are no blank lines (list items)
|
|
|
|
in the data.
|
|
|
|
|
2022-01-20 09:46:24 -08:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
**Returns**:
|
2022-01-20 09:46:24 -08:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
|
|
|
|
List of Dictionaries
|
2022-01-20 09:46:24 -08:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
<a id="jc.parsers.universal.sparse_table_parse"></a>
|
2022-01-20 09:46:24 -08:00
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
#### sparse\_table\_parse
|
2022-01-20 09:46:24 -08:00
|
|
|
|
|
|
|
```python
|
2022-01-25 17:07:47 -08:00
|
|
|
def sparse_table_parse(data, delim='\u2063')
|
2022-01-20 09:46:24 -08:00
|
|
|
```
|
|
|
|
|
|
|
|
Parse tables with missing column data or with spaces in column data.
|
|
|
|
|
2022-01-25 17:07:47 -08:00
|
|
|
**Arguments**:
|
|
|
|
|
|
|
|
|
|
|
|
- `data` - (list) Text data to parse that has been split into lines
|
|
|
|
via .splitlines(). Item 0 must be the header row.
|
|
|
|
Any spaces in header names should be changed to
|
|
|
|
underscore '_'. You should also ensure headers are
|
|
|
|
lowercase by using .lower(). Do not change the
|
|
|
|
position of header names as the positions are used
|
|
|
|
to find the data.
|
|
|
|
|
|
|
|
Also, ensure there are no blank lines (list items)
|
|
|
|
in the data.
|
|
|
|
|
|
|
|
- `delim` - (string) Delimiter to use. By default `u\\2063`
|
|
|
|
(invisible separator) is used since it is unlikely
|
|
|
|
to ever be seen in terminal output. You can change
|
|
|
|
this for troubleshooting purposes or if there is a
|
|
|
|
delimiter conflict with your data.
|
|
|
|
|
|
|
|
|
|
|
|
**Returns**:
|
|
|
|
|
|
|
|
|
|
|
|
List of Dictionaries
|
2022-01-20 09:46:24 -08:00
|
|
|
|