Find files using regular expression to feed them to Xarray.
Project description
Xarray-regex
Find files based on regular expression to pass them to Xarray
Xarray-regex allows to find files based on regular expressions, in order to feed them to Xarray. It allows to easily create regular expressions using 'Matchers', to fix some elements of the expressions to select only certain files, and to easily retrieve information from filenames.
Minimal example
The following example will find files with names Data/[month]/SST_[date].nc
(and only those!).
For each file, the date can be retrieved as a datetime object.
from xarray_regex import FileFinder, library
finder = FileFinder('/.../Data', r'%(m)/SST_%(Y)%(m)%(d)\.nc')
files = finder.get_files()
for f in files:
print(f, library.get_date(finder.get_matches(f, relative=False)))
We can also only select some files, for instance only the first day of each month:
finder.fix_matcher('d', '01')
print(finder.get_files())
Requirements
Python >= 3.7.
Installation
From pip:
pip install xarray-regex
From source:
git clone https://github.com/Descanonge/xarray-regex.git
cd xarray-regex
pip install -e .
Documentation
Documentation is available at xarray-regex.readthedocs.io.
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
Built Distribution
File details
Details for the file xarray-regex-0.1.0.tar.gz
.
File metadata
- Download URL: xarray-regex-0.1.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c34a630fa182a6f331c5328d160447286296192c29f5553013c508be19b760b5 |
|
MD5 | 8ebd90e4dae6ea94f5f90aa2d4d51804 |
|
BLAKE2b-256 | 1d9a69b1ddad09b8f71e97ad826ef78bb8d846c78f0d36ca151c5ffccb9a33a3 |
File details
Details for the file xarray_regex-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: xarray_regex-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73b05ae8cc95a4d0b5a79bd1eee686bffe8f91789092c730e6d2999d345d6241 |
|
MD5 | f6762d1fc46bdb192657fa725cb2c90f |
|
BLAKE2b-256 | a5547b4f05b88edff32f424454fa1c00c188fd88eb4158a1939ec8c1af9f9818 |