mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-10-08 23:22:21 +02:00
doc update
This commit is contained in:
122
docs/parsers/asciitable_m.md
Normal file
122
docs/parsers/asciitable_m.md
Normal file
@@ -0,0 +1,122 @@
|
||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||
<a id="jc.parsers.asciitable_m"></a>
|
||||
|
||||
# jc.parsers.asciitable\_m
|
||||
|
||||
jc - JSON Convert `asciitable-m` parser
|
||||
|
||||
This parser converts various styles of ASCII and Unicode text tables with
|
||||
multi-line rows. Tables must have a header row and separator line between
|
||||
rows.
|
||||
|
||||
For example:
|
||||
|
||||
╒══════════╤═════════╤════════╕
|
||||
│ foo │ bar baz │ fiz │
|
||||
│ │ │ buz │
|
||||
╞══════════╪═════════╪════════╡
|
||||
│ good day │ 12345 │ │
|
||||
│ mate │ │ │
|
||||
├──────────┼─────────┼────────┤
|
||||
│ hi there │ abc def │ 3.14 │
|
||||
│ │ │ │
|
||||
╘══════════╧═════════╧════════╛
|
||||
|
||||
Cells with multiple lines within rows will be joined with a new-line
|
||||
character ('\n').
|
||||
|
||||
Headers (keys) are converted to snake case and newlines between multi-line
|
||||
headers are joined with an underscore. All values are returned as strings.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ cat table.txt | jc --asciitable-m
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('asciitable_m', asciitable-string)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"column_name1": string,
|
||||
"column_name2": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ echo '
|
||||
> +----------+---------+--------+
|
||||
> | foo | bar | baz |
|
||||
> | | | buz |
|
||||
> +==========+=========+========+
|
||||
> | good day | 12345 | |
|
||||
> | mate | | |
|
||||
> +----------+---------+--------+
|
||||
> | hi there | abc def | 3.14 |
|
||||
> | | | |
|
||||
> +==========+=========+========+' | jc --asciitable-m -p
|
||||
[
|
||||
{
|
||||
"foo": "good day\nmate",
|
||||
"bar": "12345",
|
||||
"baz_buz": ""
|
||||
},
|
||||
{
|
||||
"foo": "hi there",
|
||||
"bar": "abc def",
|
||||
"baz_buz": "3.14"
|
||||
}
|
||||
]
|
||||
|
||||
$ echo '
|
||||
> ╒══════════╤═════════╤════════╕
|
||||
> │ foo │ bar │ baz │
|
||||
> │ │ │ buz │
|
||||
> ╞══════════╪═════════╪════════╡
|
||||
> │ good day │ 12345 │ │
|
||||
> │ mate │ │ │
|
||||
> ├──────────┼─────────┼────────┤
|
||||
> │ hi there │ abc def │ 3.14 │
|
||||
> │ │ │ │
|
||||
> ╘══════════╧═════════╧════════╛' | jc --asciitable-m -p
|
||||
[
|
||||
{
|
||||
"foo": "good day\nmate",
|
||||
"bar": "12345",
|
||||
"baz_buz": ""
|
||||
},
|
||||
{
|
||||
"foo": "hi there",
|
||||
"bar": "abc def",
|
||||
"baz_buz": "3.14"
|
||||
}
|
||||
]
|
||||
|
||||
<a id="jc.parsers.asciitable_m.parse"></a>
|
||||
|
||||
### parse
|
||||
|
||||
```python
|
||||
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
|
||||
```
|
||||
|
||||
Main text parsing function
|
||||
|
||||
Parameters:
|
||||
|
||||
data: (string) text data to parse
|
||||
raw: (boolean) unprocessed output if True
|
||||
quiet: (boolean) suppress warning messages if True
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
|
||||
### Parser Information
|
||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
Reference in New Issue
Block a user