A (python) indexer for large collections of json files
Project description
# JsonPydexer
A (python) indexer for large collections of json files.
In development and probably not good for general use yet.
`pip install JsonPydexer`
## Usage
### Starting from zero
```python
from JsonPydexer import JsonPydexer
# initialize with the root directory containing your json files
jp = JsonPydexer("test_data/1")
# index on your keys. provide a list of keynamess. keyname elements can be a string for a
# field at root level, or a list of strings for nested fields
jp.index(["id", ["details", "name"]])
```
### Opening an existing index
```python
# initialize with the root directory containing your json files and .jp.pkl
jp = JsonPydexer("test_data/1")
# get all the files that match a search string for non-unique index
search_string = "Foo"
for filename in jp.get_files(["key_name"], search_string):
with open(filename, "r") as f:
print(f)
# get the file matching a search string for a unique index
search_string = "Bar"
with open(jp.get_file(["unique_key_name"], search_string), "r") as f:
print(f)
```
### Added, removed, or modified JSON files? Updating
```python
jp = JsonPydexer("test_data/1")
jp.update()
```
New files in the directory will be added to the index. Coming soon are: removing files not present in the directory from the index, and checking for modified files in the directory.
A (python) indexer for large collections of json files.
In development and probably not good for general use yet.
`pip install JsonPydexer`
## Usage
### Starting from zero
```python
from JsonPydexer import JsonPydexer
# initialize with the root directory containing your json files
jp = JsonPydexer("test_data/1")
# index on your keys. provide a list of keynamess. keyname elements can be a string for a
# field at root level, or a list of strings for nested fields
jp.index(["id", ["details", "name"]])
```
### Opening an existing index
```python
# initialize with the root directory containing your json files and .jp.pkl
jp = JsonPydexer("test_data/1")
# get all the files that match a search string for non-unique index
search_string = "Foo"
for filename in jp.get_files(["key_name"], search_string):
with open(filename, "r") as f:
print(f)
# get the file matching a search string for a unique index
search_string = "Bar"
with open(jp.get_file(["unique_key_name"], search_string), "r") as f:
print(f)
```
### Added, removed, or modified JSON files? Updating
```python
jp = JsonPydexer("test_data/1")
jp.update()
```
New files in the directory will be added to the index. Coming soon are: removing files not present in the directory from the index, and checking for modified files in the directory.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
JsonPydexer-0.3.0.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for JsonPydexer-0.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 765a09c056273cf3fb9b17b170bc4c0cb2451780f0406faeb90e6dcddfa8d0db |
|
MD5 | 74e5df44cc911ebe2d63049fe93acef3 |
|
BLAKE2b-256 | f21b273979bf9294bce093fa79c60faa1e5dbfbc024f60b9fd6e800b9398f409 |