Find files using a simple syntax.
Project description
FileFinder
Find files using a simple syntax.
FileFinder allows to specify the structure of filenames with a simple syntax. Parts of the file structure varying from file to file can be indicated with format strings or regular expressions, or with pre-defined defaults (mainly for dates). Once setup, it can:
- Find corresponding files in a directory
- Parse information from the filenames
- Select only filenames with specific values
- Generate filenames
The package also interface easily with xarray.open_mfdataset.
Quick examples
The following example will find all files with the structure Data/[month]/Temperature_[depth]_[date].nc:
finder = Finder('/.../Data', '%(m)/Temperature_%(depth:fmt=d)_%(Y)%(m)%(d).nc')
files = finder.get_files()
We can also only select some files, for instance the first day of each month:
finder.fix_matcher('d', 1)
files = finder.get_files()
We can retrieve values from found files:
filename, matches = finder.files[0]
depth = matches.get_matches('depth').get_value()
date = filefinder.library.get_date(matches)
And we can generate a filename with a set of parameters:
finder.get_filename(depth=100, Y=2000, m=1, d=1)
# Specifying the day is optional since we already fixed it to 1.
Requirements
Python >= 3.7.
Installation
From pip:
pip install filefinder
From source:
git clone https://github.com/Descanonge/filefinder.git
cd filefinder
pip install -e .
Documentation
Documentation is available at filefinder.readthedocs.io.
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 filefinder-0.3.0.tar.gz.
File metadata
- Download URL: filefinder-0.3.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41417fd84f5b853686c3a9e798c7449709a3b987e5bee2883013ec4e239c5f65
|
|
| MD5 |
784479fd7fa1a7a7c18781a9eae50455
|
|
| BLAKE2b-256 |
d2c617b0b0095a61460b82ef58d844a05566192a3cb530cd8222c4251a0fd971
|
File details
Details for the file filefinder-0.3.0-py3-none-any.whl.
File metadata
- Download URL: filefinder-0.3.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f104305db03a594e64c55e8a3c2877f1fa2e223a798bc8828cc997a1afbb9990
|
|
| MD5 |
27f11cea5ff09e4791b322696425e86f
|
|
| BLAKE2b-256 |
e63ce94f10d733f895af6aa11349fe9862b5a95a887678a33444967570e55ce0
|