A data structure for quickly dealing with nested data in different formats
Project description
QueryTree
QueryTree is a python data structure that lets you quickly access deeply nested data and load/save it in any major format.
With QueryTree, you don't have to check for the esistance of (or create) any intermediate nodes.
json_str = """
{
"foo": {
"bar": [
{
"baz": {
"n": 1
}
},
{
"baz": {
"n": 1
},
"buz": {
"k": 2
}
}
]
}
}
"""
tree = Tree.parse_json(json_str)
print(tree['foo.bar.0.baz.n']) # 1
print(tree['foo.bar.1.buz.k']) # 2
# accessing nonexistant locations isn't a problem
print(tree['foo.bar.0.buz.k']) # None
print(tree['something.else']) # None
# assign values
tree['foo.bar.0.baz.n'] = 99
tree['foo.foo'] = {"myvalue": "a value"}
# save as any format
print(tree.to_yaml())
Outputs:
foo:
bar:
- baz:
n: 99
- baz:
n: 1
buz:
k: 2
foo:
myvalue: a value
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
querytree-0.1.1.tar.gz
(8.5 kB
view details)
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 querytree-0.1.1.tar.gz.
File metadata
- Download URL: querytree-0.1.1.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6febd1c83a896a2422aff9d9e1be3bdde82cfa12b96d56e31da16ae86d21bdad
|
|
| MD5 |
10caca05eb45ef0a41fd3145e45efb23
|
|
| BLAKE2b-256 |
42aea0f1095154c34ed603cca7ac6b2e0c246bd6188fb35660d3be7418f4fa79
|
File details
Details for the file querytree-0.1.1-py3-none-any.whl.
File metadata
- Download URL: querytree-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d235197b46389773c67e40e9e7b3dbf66014048b5bf71d30acf39cc6d34dacb4
|
|
| MD5 |
e047687497eff07ff8b8fcc25c1d85fc
|
|
| BLAKE2b-256 |
12fd6e104e9d78f09f5c594c82a6b3f29467e63605a6cb5eb2d8b5487b59d1fa
|