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

128 lines
2.9 KiB
Markdown
Raw Normal View History

2022-12-13 12:13:27 -08:00
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.cbt"></a>
# jc.parsers.cbt
2022-12-16 12:54:07 -08:00
jc - JSON Convert `cbt` command output parser (Google Bigtable)
2022-12-13 12:13:27 -08:00
Parses the human-, but not machine-, friendly output of the cbt command (for
2022-12-16 12:54:07 -08:00
Google's Bigtable).
2022-12-13 12:13:27 -08:00
No effort is made to convert the data types of the values in the cells.
2022-12-13 13:30:50 -08:00
The `timestamp_epoch` calculated timestamp field is naive. (i.e. based on
the local time of the system the parser is run on)
2022-12-13 12:13:27 -08:00
2022-12-13 13:30:50 -08:00
The `timestamp_epoch_utc` calculated timestamp field is timezone-aware and
is only available if the timestamp has a UTC timezone.
The `timestamp_iso` calculated timestamp field will only include UTC
timezone information if the timestamp has a UTC timezone.
Raw output contains all cells for each column (including timestamps), while
the normal output contains only the latest value for each column.
2022-12-13 12:13:27 -08:00
Usage (cli):
$ cbt | jc --cbt
or
$ jc cbt
Usage (module):
import jc
result = jc.parse('cbt', cbt_command_output)
Schema:
[
{
"key": string,
"cells": {
2022-12-13 13:46:33 -08:00
<string>: { # column family
<string>: string # column: value
2022-12-13 12:13:27 -08:00
}
}
}
]
Schema (raw):
[
{
"key": string,
"cells": [
{
"column_family": string,
"column": string,
2022-12-13 13:46:33 -08:00
"value": string,
"timestamp_iso": string,
"timestamp_epoch": integer,
"timestamp_epoch_utc": integer
2022-12-13 12:13:27 -08:00
}
]
}
]
Examples:
$ cbt -project=$PROJECT -instance=$INSTANCE lookup $TABLE foo | jc --cbt -p
[
{
"key": "foo",
"cells": {
"foo": {
"bar": "baz"
}
}
}
]
$ cbt -project=$PROJECT -instance=$INSTANCE lookup $TABLE foo | jc --cbt -p -r
[
{
"key": "foo",
"cells": [
{
"column_family": "foo",
"column": "bar",
2022-12-13 13:46:33 -08:00
"value": "baz1",
"timestamp_iso": "1970-01-01T01:00:00",
"timestamp_epoch": 32400,
"timestamp_epoch_utc": null
2022-12-13 12:13:27 -08:00
}
]
}
]
<a id="jc.parsers.cbt.parse"></a>
### parse
```python
def parse(data: str,
raw: bool = False,
2024-03-14 22:46:52 -07:00
quiet: bool = False) -> List[Dict[str, Any]]
2022-12-13 12:13:27 -08:00
```
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
2023-12-21 14:55:21 -08:00
Source: [`jc/parsers/cbt.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/cbt.py)
2022-12-13 12:13:27 -08:00
Version 1.0 by Andreas Weiden (andreas.weiden@gmail.com)