eases the saving and reading of files within a structured folder tree
Project description
Filoc File Locator
This tiny library eases the saving and reading of files within a structured folder tree.
Example
from filoc import Filoc
loc = Filoc('/data/simid={simid:d}/epid={epid:d}/settings.json')
path1 = loc.build_path(simid=0, epid=1) # /data/simid=0/epid=1/settings.json
with open(path1, 'w') as f:
f.write('Coucou')
path2 = loc.build_path(simid=0, epid=2) # /data/simid=0/epid=2/settings.json
with open(path2, 'w') as f:
f.write('Salut')
paths = loc.find_paths(simid=0) # ['/data/simid=0/epid=1/settings.json', '/data/simid=0/epid=2/settings.json']
props = loc.extract_properties(paths[0]) # { 'simid': 0, 'epid': 1 }
Install
pip install filoc
Syntax
The Filoc constructor accepts a file path/url, which will finally be interpreted by fsspec. That way, it is possible to access ftp, HDFS or any other file repository supported by fsspec. The path is at the same time a format string with named placeholder, which will be parsed by the parse library. Each placeholder defines a property associated to the files to save or retrieve.
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
filoc-0.0.1-py3-none-any.whl
(3.8 kB
view details)
File details
Details for the file filoc-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: filoc-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e05a7ec9bb07588d3545e3c110197f2ce35f3c938c696cd7bdff01e51c6bfe4 |
|
MD5 | ab2d47b0a0562d42fa2c3b863f69a542 |
|
BLAKE2b-256 | a55e8e27e62e2a9ec50e820be93f163cc849de96f1b249b29ee979c79f4b463e |