1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

add universal parser docs

This commit is contained in:
Kelly Brazil
2022-01-20 09:46:24 -08:00
parent d09529ac30
commit a4e34b0053
2 changed files with 63 additions and 0 deletions

View File

@ -12,6 +12,9 @@ pydocmd simple lib+ > ../docs/lib.md
echo Building docs for: utils echo Building docs for: utils
pydocmd simple utils+ > ../docs/utils.md pydocmd simple utils+ > ../docs/utils.md
echo Building docs for: universal parser
pydocmd simple jc.parsers.universal+ > ../docs/parsers/universal.md
# a bit of inception here... jc is being used to help # a bit of inception here... jc is being used to help
# automate the generation of its own documentation. :) # automate the generation of its own documentation. :)

60
docs/parsers/universal.md Normal file
View File

@ -0,0 +1,60 @@
# jc.parsers.universal
jc - JSON CLI output utility universal Parsers
## simple_table_parse
```python
simple_table_parse(data)
```
Parse simple tables. The last column may contain data with spaces
code adapted from Conor Heine at:
https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501
Parameters:
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.
Returns:
List of Dictionaries
## sparse_table_parse
```python
sparse_table_parse(data, delim='\u2063')
```
Parse tables with missing column data or with spaces in column data.
Parameters:
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