SBSV: Square Brackets Separated Values
Project description
SBSV: square bracket separated values
Install
python3 -m pip install svsb
Use
You can read this log-like data:
[meta-data] [id 1] [format string]
[meta-data] [id 2] [format token]
[data] [string] [id 1] [actual some long string...]
[data] [token] [id 2] [actual [some] [multiple] [tokens]]
[stat] [rows 2]
import sbsv
parser = sbsv.parser()
parser.add_schema("[meta-data] [id: int] [format: str]")
parser.add_schema("[data] [string] [id: int] [actual: str]")
parser.add_schema("[data] [token] [id: int] [actual: list[str]]")
parser.add_schema("[stat] [rows: int]")
with open("testfile.svsb", "r") as f:
result = parser.load(f)
Result would looks like:
{
"meta-data": [{"id": 1, "format": "string"}, {"id": 2, "format": "string"}],
"data": {
"string": [{"id": 1, "actual": "some long string..."}],
"token": [{"id": 2, "actual": ["some", "multiple", "tokens"]}]
},
"stat": [{"rows": 2}]
}
Details
Basic schema
Schema is consisted with schema name, variable name and type annotation.
[schema-name] [var-name: type]
You can use [A-Za-z0-9-_] for names.
Sub schema
[my-schema] [sub-schema] [some: int] [other: str] [data: bool]
You can add any sub schema. But if you add sub schema, you cannot add new schema with same schema name without sub schema.
[my-schema] [no: int] [sub: str] [schema: str]
# this will cause error
Ignore
[2024-03-04 13:22:56] [DEBUG] [necessary] [from] [this part]
Regular log file may contain unnecessary data. You can specify parser to ignore [2024-03-04 13:22:56] [DEBUG] part.
parser.add_schema("[$ignore] [$ignore] [necessary] [from] [this: str]")
Primitive types
Primitive types are str, int, float, bool, null.
Complex types
You can use list.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sbsv-0.0.1.tar.gz.
File metadata
- Download URL: sbsv-0.0.1.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81a592c4359f293e5614dccbea00f5a6511467c0499cb6a87ccbfba8c314daeb
|
|
| MD5 |
9f17799287a976e0c0c45519d1378893
|
|
| BLAKE2b-256 |
7ecaeb0d605028e7812fb9711fdf276028d4f46cde9109cfe6ace09e9ebf3fb2
|
File details
Details for the file sbsv-0.0.1-py3-none-any.whl.
File metadata
- Download URL: sbsv-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bd4a317f7fa7e3e9f705168307b7ddd9aea1afa090ec6ad73b67db4c3f53ecd
|
|
| MD5 |
b3fb564ead461577d71be71fe91b6cf9
|
|
| BLAKE2b-256 |
6b917c4e529178a0cce6a66f10393e1534059294b48639be27ddbe65133e7390
|