A library to read and manipulate nested data structures, particularly ones read from JSON files
Project description
DataDelve
Working with complex nested data can be tedious. If you have to access any objects that are four layers deep in a JSON response from a web service, you quickly tire of writing square brackets. Much better would be to have a simple way of accessing data through a simple syntax. jsonpointer is a perfect match, it looks just like paths through a filesystem. Applying this information to the data structures makes it easy and convenient.
Usage
from datadelve import DataDelver
data = ["your annoying data here"]
delver = DataDelver(data)
element = delver.get("/dict/keys/and/1/list/index")
subset = delver.cd("/particular/key/to/focus/on")
delver.set("/path/to/change", "new")
delver.delete("/bad")
Support
This package grew around a series of JSON files, so that is the primary focus. It therefore
expects data structures with dicts and lists. As the implementation is turned over to
jsonpointer, it will work for anything that implements __getitem__(str)
or that is registered
as a collections.abc.Sequence
and implements __getitem__(int)
.
Raw data, loaded from whatever source, is accepted. So are JSON files. These have the added benefit of being flyweight instances, so all views on the same file reference the same object. This way none of them can get out of sync and make writes indeterminate as to what updates have actually been made. As YAML isn't in the standard library, I've split support for that into a separate project: datadelve_yaml. YAML files are treated the same as JSON.
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
File details
Details for the file datadelve-0.8.4.tar.gz
.
File metadata
- Download URL: datadelve-0.8.4.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.8.10 Linux/5.4.0-125-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c8846faaa7a54566fc7c7de837f20d0c6db2c30122fca7f8fdf7ee9830c48d6 |
|
MD5 | 626d0d4916e1bb62b770367ed619151e |
|
BLAKE2b-256 | e3705ba019e0691fd056e37b7d8fe944cd2a150f7966e6f95551823947ab0229 |
File details
Details for the file datadelve-0.8.4-py3-none-any.whl
.
File metadata
- Download URL: datadelve-0.8.4-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.8.10 Linux/5.4.0-125-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5b32db7f40612842e85218bc240a66400a734db47791ea2656f3937c67e04ee |
|
MD5 | ad8136fb72ea9dec15e4d76e81d9e748 |
|
BLAKE2b-256 | 09d415e1612fe74ae7880d4d7765d7eb570ecba1fb946da73b2cc26a5d08eed6 |