-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #213 from kellyjonbrazil/dev
Dev v1.18.6
- Loading branch information
Showing
237 changed files
with
4,289 additions
and
1,242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
[Home](https://kellyjonbrazil.github.io/jc/) | ||
<a id="jc.parsers.asciitable"></a> | ||
|
||
# jc.parsers.asciitable | ||
|
||
jc - JSON Convert `asciitable` parser | ||
|
||
This parser converts ASCII and Unicode text tables with single-line rows. | ||
|
||
Column headers must be at least two spaces apart from each other and must | ||
be unique. | ||
|
||
For example: | ||
|
||
╒══════════╤═════════╤════════╕ | ||
│ foo │ bar │ baz │ | ||
╞══════════╪═════════╪════════╡ | ||
│ good day │ │ 12345 │ | ||
├──────────┼─────────┼────────┤ | ||
│ hi there │ abc def │ 3.14 │ | ||
╘══════════╧═════════╧════════╛ | ||
|
||
or | ||
|
||
+-----------------------------+ | ||
| foo bar baz | | ||
+-----------------------------+ | ||
| good day 12345 | | ||
| hi there abc def 3.14 | | ||
+-----------------------------+ | ||
|
||
or | ||
|
||
| foo | bar | baz | | ||
|----------|---------|--------| | ||
| good day | | 12345 | | ||
| hi there | abc def | 3.14 | | ||
|
||
or | ||
|
||
foo bar baz | ||
--------- -------- ------ | ||
good day 12345 | ||
hi there abc def 3.14 | ||
|
||
or | ||
|
||
foo bar baz | ||
good day 12345 | ||
hi there abc def 3.14 | ||
|
||
etc... | ||
|
||
Headers (keys) are converted to snake-case. All values are returned as | ||
strings, except empty strings, which are converted to None/null. | ||
|
||
Usage (cli): | ||
|
||
$ cat table.txt | jc --asciitable | ||
|
||
Usage (module): | ||
|
||
import jc | ||
result = jc.parse('asciitable', asciitable_string) | ||
|
||
Schema: | ||
|
||
[ | ||
{ | ||
"column_name1": string, # empty string is null | ||
"column_name2": string # empty string is null | ||
} | ||
] | ||
|
||
Examples: | ||
|
||
$ echo ' | ||
> ╒══════════╤═════════╤════════╕ | ||
> │ foo │ bar │ baz │ | ||
> ╞══════════╪═════════╪════════╡ | ||
> │ good day │ │ 12345 │ | ||
> ├──────────┼─────────┼────────┤ | ||
> │ hi there │ abc def │ 3.14 │ | ||
> ╘══════════╧═════════╧════════╛' | jc --asciitable -p | ||
[ | ||
{ | ||
"foo": "good day", | ||
"bar": null, | ||
"baz": "12345" | ||
}, | ||
{ | ||
"foo": "hi there", | ||
"bar": "abc def", | ||
"baz": "3.14" | ||
} | ||
] | ||
|
||
$ echo ' | ||
> foo bar baz | ||
> --------- -------- ------ | ||
> good day 12345 | ||
> hi there abc def 3.14' | jc --asciitable -p | ||
[ | ||
{ | ||
"foo": "good day", | ||
"bar": null, | ||
"baz": "12345" | ||
}, | ||
{ | ||
"foo": "hi there", | ||
"bar": "abc def", | ||
"baz": "3.14" | ||
} | ||
] | ||
|
||
<a id="jc.parsers.asciitable.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) |
Oops, something went wrong.