Name | file-navigator JSON |
Version |
0.1.4
JSON |
| download |
home_page | None |
Summary | Flexible directory scanner, file path manager, and customizable file loader—all in one |
upload_time | 2025-01-11 18:32:03 |
maintainer | Qomp4ss |
docs_url | None |
author | Qomp4ss |
requires_python | >=3.6 |
license | MIT License Copyright (c) 2024 Qomp4ss Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
file
flexible
manager
directory
scanner
path
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# file-navigator
Flexible directory scanner, file path manager, and customizable file loader-all in one.
## Features
- **File Searching**: Locate files using simple equality and inclusion checks, as well as advanced string matching options like regular expressions and glob patterns. These matching options can be applied to both file names and extensions.
- **Filtering**: Filter file paths based on specific string patterns, enhancing the precision of your searches.
- **Grouping**: Organize file paths by file names, extensions, or root paths, with support for string pattern matching in each grouping option.
- **Extensible Interface**: Provides an extendable interface for developing custom data loader objects, complemented by a flexible loader factory to accommodate various data loading requirements.
- **Method Chaining**: Seamlessly chain methods to achieve your goals efficiently, enhancing code readability and fluency.
## Installation
### From Source:
`pip install git+https://github.com/Qomp4ss/file-navigator.git`
For specific instalations please use [VCS Support](https://pip.pypa.io/en/stable/topics/vcs-support/) as a reference
### From PyPi:
`pip install file-navigator`
## Examples
### Introduction
To utilize all features of file-navigator, only two objects are needed:
+ __PathFinder__ - interface for all file-path operations (adding/deleting directories, find, groupby, select_paths)
+ __ABLoader__ - interface for creating custom Loader objects, which must be injected into PathFinder.load method
Additionally the package contains two Loder objects:
1. __BaseLoader__ - simple Loader factory that implements ABLoader interface allowing to dynamically create loader objects,
based on a dictionary with loading functions and extension_type(s) pairs
2. __PDLoader__ - implementation of BaseLoader class adapting **pandas reader functions** for loading data.
### Prerequisites
Example usecases, aprat from __PathFinder__ will be also utilizing PDLoader, to load tabular data:
```python
from file_navigator import PathFinder
from file_navigator import PDLoader
```
Additionaly the following directory structure in a D drive will be assumed:
```
CURRENCIES
│ Portfloio.xlsx
│ Porfolio Forecast.xlsx
│
└───APAC
│ │ xagjpy.txt
│ │ xaujpy.txt
│ │
│ └───Calculations
│ │ transformations.csv
│ │ cov_matrix.csv
│
└───EMEA
│ chfeur.txt
│ chfgbp.txt
│ eurgbp.txt
```
---
### Example 1. Shallow search
Finding and loading xagjpy.txt and xaujpy.txt files from D:\CURRENCIES\APAC directory
```python
>>> path_finder_shallow = PathFinder({r'D:\CURRENCIES\APAC':False})
>>> apac_pairs = path_finder_shallow.find('.*', 'txt', 'regex', 'eq').load(PDLoader)
```
```python
>>> apac_pairs[0].head()
```
| | TICKER | PER | DATE | TIME | OPEN | HIGH | LOW | CLOSE | VOL | OPENINT |
|---:|:-----------|--------:|---------:|---------:|---------:|---------:|--------:|----------:|--------:|------------:|
| 0 | XAUJPY | 5 | 20220817 | 0 | 238431 | 238471 | 238427 | 238446 | 0 | 0 |
| 1 | XAUJPY | 5 | 20220817 | 500 | 238446 | 238446 | 238346 | 238346 | 0 | 0 |
| 2 | XAUJPY | 5 | 20220817 | 1000 | 238346 | 238366 | 238323 | 238353 | 0 | 0 |
| 3 | XAUJPY | 5 | 20220817 | 1500 | 238351 | 238373 | 238302 | 238325 | 0 | 0 |
| 4 | XAUJPY | 5 | 20220817 | 2000 | 238325 | 238386 | 238318 | 238361 | 0 | 0 |
```python
>>> apac_pairs[1].head()
```
| | TICKER | PER | DATE | TIME | OPEN | HIGH | LOW | CLOSE | VOL | OPENINT |
|---:|:-----------|--------:|---------:|---------:|---------:|---------:|--------:|----------:|--------:|------------:|
| 0 | XAGJPY | 5 | 20220817 | 0 | 2704.16 | 2706.43 | 2704.13 | 2706.42 | 0 | 0 |
| 1 | XAGJPY | 5 | 20220817 | 500 | 2706.42 | 2706.98 | 2704.18 | 2704.18 | 0 | 0 |
| 2 | XAGJPY | 5 | 20220817 | 1000 | 2704.18 | 2704.76 | 2703.77 | 2704.33 | 0 | 0 |
| 3 | XAGJPY | 5 | 20220817 | 1500 | 2704.31 | 2704.31 | 2703.04 | 2703.54 | 0 | 0 |
| 4 | XAGJPY | 5 | 20220817 | 2000 | 2703.54 | 2704.65 | 2703.41 | 2704.07 | 0 | 0 |
### Example 2. Deep search
Finding all files from Calculations directory and only Portfolio.xlsx file from CURRENCIES directory
```python
>>> portfolio = path_finder.find('^(?:(?!Forecast).)+$', '.xlsx|.csv', 'regex', 'regex')
>>> portfolio.paths
```
### Example 3. Deep search with group-by
Finding all txt files and grouping them by the folder they are in
```python
>>> path_finder = PathFinder({r'D:\CURRENCIES':True})
>>> pairs = path_finder.find('*', 'txt', 'glob').groupby('path')
>>> pairs['D:\\CURRENCIES\\APAC'].paths
>>> pairs[ 'D:\\CURRENCIES\\EMEA'].paths
```
### Example 4. Deep search with filtering and group-by
Loading all txt and csv files, grouping them by extension and filtering txt files from APAC
```python
>>> text_files = path_finder.find('*', '.txt|.csv', 'glob', 'regex').groupby('ext')
>>> csv_files = text_files['.csv']
>>> csv_files.paths
>>> txt_EMEA_files = text_files['.txt'].select_paths('EMEA', 'isin')
>>> txt_EMEA_files.paths
```
---
## License
[MIT](LICENSE)
Raw data
{
"_id": null,
"home_page": null,
"name": "file-navigator",
"maintainer": "Qomp4ss",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "Qomp4ss <imaggine@gmail.com>",
"keywords": "file, flexible, manager, directory, scanner, path",
"author": "Qomp4ss",
"author_email": "Qomp4ss <imaggine@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/a7/4d/c289d293297ced467f334f34aa0bd93280a41667375715ba8566d77d98a6/file_navigator-0.1.4.tar.gz",
"platform": null,
"description": "# file-navigator\r\nFlexible directory scanner, file path manager, and customizable file loader-all in one.\r\n## Features\r\n- **File Searching**: Locate files using simple equality and inclusion checks, as well as advanced string matching options like regular expressions and glob patterns. These matching options can be applied to both file names and extensions.\r\n\r\n- **Filtering**: Filter file paths based on specific string patterns, enhancing the precision of your searches.\r\n\r\n- **Grouping**: Organize file paths by file names, extensions, or root paths, with support for string pattern matching in each grouping option.\r\n\r\n- **Extensible Interface**: Provides an extendable interface for developing custom data loader objects, complemented by a flexible loader factory to accommodate various data loading requirements.\r\n\r\n- **Method Chaining**: Seamlessly chain methods to achieve your goals efficiently, enhancing code readability and fluency.\r\n\r\n## Installation\r\n### From Source:\r\n`pip install git+https://github.com/Qomp4ss/file-navigator.git`\r\n\r\nFor specific instalations please use [VCS Support](https://pip.pypa.io/en/stable/topics/vcs-support/) as a reference\r\n\r\n### From PyPi:\r\n`pip install file-navigator`\r\n \r\n## Examples\r\n### Introduction \r\nTo utilize all features of file-navigator, only two objects are needed:\r\n+ __PathFinder__ - interface for all file-path operations (adding/deleting directories, find, groupby, select_paths)\r\n+ __ABLoader__ - interface for creating custom Loader objects, which must be injected into PathFinder.load method\r\n\r\nAdditionally the package contains two Loder objects:\r\n1. __BaseLoader__ - simple Loader factory that implements ABLoader interface allowing to dynamically create loader objects, \r\nbased on a dictionary with loading functions and extension_type(s) pairs\r\n2. __PDLoader__ - implementation of BaseLoader class adapting **pandas reader functions** for loading data. \r\n\r\n### Prerequisites\r\nExample usecases, aprat from __PathFinder__ will be also utilizing PDLoader, to load tabular data:\r\n\r\n```python\r\nfrom file_navigator import PathFinder\r\nfrom file_navigator import PDLoader\r\n```\r\n\r\nAdditionaly the following directory structure in a D drive will be assumed:\r\n```\r\nCURRENCIES\r\n\u2502 Portfloio.xlsx\r\n\u2502 Porfolio Forecast.xlsx\r\n\u2502\r\n\u2514\u2500\u2500\u2500APAC\r\n\u2502 \u2502 xagjpy.txt\r\n\u2502 \u2502 xaujpy.txt\r\n\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500Calculations\r\n\u2502 \u2502 transformations.csv\r\n\u2502 \u2502 cov_matrix.csv \r\n\u2502 \r\n\u2514\u2500\u2500\u2500EMEA\r\n \u2502 chfeur.txt\r\n \u2502 chfgbp.txt\r\n \u2502 eurgbp.txt\r\n```\r\n\r\n---\r\n### Example 1. Shallow search\r\nFinding and loading xagjpy.txt and xaujpy.txt files from D:\\CURRENCIES\\APAC directory\r\n```python\r\n>>> path_finder_shallow = PathFinder({r'D:\\CURRENCIES\\APAC':False})\r\n>>> apac_pairs = path_finder_shallow.find('.*', 'txt', 'regex', 'eq').load(PDLoader)\r\n```\r\n```python\r\n>>> apac_pairs[0].head()\r\n```\r\n| | TICKER | PER | DATE | TIME | OPEN | HIGH | LOW | CLOSE | VOL | OPENINT |\r\n|---:|:-----------|--------:|---------:|---------:|---------:|---------:|--------:|----------:|--------:|------------:|\r\n| 0 | XAUJPY | 5 | 20220817 | 0 | 238431 | 238471 | 238427 | 238446 | 0 | 0 |\r\n| 1 | XAUJPY | 5 | 20220817 | 500 | 238446 | 238446 | 238346 | 238346 | 0 | 0 |\r\n| 2 | XAUJPY | 5 | 20220817 | 1000 | 238346 | 238366 | 238323 | 238353 | 0 | 0 |\r\n| 3 | XAUJPY | 5 | 20220817 | 1500 | 238351 | 238373 | 238302 | 238325 | 0 | 0 |\r\n| 4 | XAUJPY | 5 | 20220817 | 2000 | 238325 | 238386 | 238318 | 238361 | 0 | 0 |\r\n```python\r\n>>> apac_pairs[1].head()\r\n```\r\n| | TICKER | PER | DATE | TIME | OPEN | HIGH | LOW | CLOSE | VOL | OPENINT |\r\n|---:|:-----------|--------:|---------:|---------:|---------:|---------:|--------:|----------:|--------:|------------:|\r\n| 0 | XAGJPY | 5 | 20220817 | 0 | 2704.16 | 2706.43 | 2704.13 | 2706.42 | 0 | 0 |\r\n| 1 | XAGJPY | 5 | 20220817 | 500 | 2706.42 | 2706.98 | 2704.18 | 2704.18 | 0 | 0 |\r\n| 2 | XAGJPY | 5 | 20220817 | 1000 | 2704.18 | 2704.76 | 2703.77 | 2704.33 | 0 | 0 |\r\n| 3 | XAGJPY | 5 | 20220817 | 1500 | 2704.31 | 2704.31 | 2703.04 | 2703.54 | 0 | 0 |\r\n| 4 | XAGJPY | 5 | 20220817 | 2000 | 2703.54 | 2704.65 | 2703.41 | 2704.07 | 0 | 0 |\r\n\r\n\r\n### Example 2. Deep search \r\nFinding all files from Calculations directory and only Portfolio.xlsx file from CURRENCIES directory\r\n```python\r\n>>> portfolio = path_finder.find('^(?:(?!Forecast).)+$', '.xlsx|.csv', 'regex', 'regex')\r\n>>> portfolio.paths\r\n```\r\n\r\n\r\n### Example 3. Deep search with group-by\r\nFinding all txt files and grouping them by the folder they are in\r\n```python\r\n>>> path_finder = PathFinder({r'D:\\CURRENCIES':True})\r\n>>> pairs = path_finder.find('*', 'txt', 'glob').groupby('path')\r\n>>> pairs['D:\\\\CURRENCIES\\\\APAC'].paths\r\n>>> pairs[ 'D:\\\\CURRENCIES\\\\EMEA'].paths\r\n```\r\n\r\n\r\n### Example 4. Deep search with filtering and group-by \r\nLoading all txt and csv files, grouping them by extension and filtering txt files from APAC\r\n```python\r\n>>> text_files = path_finder.find('*', '.txt|.csv', 'glob', 'regex').groupby('ext')\r\n>>> csv_files = text_files['.csv']\r\n>>> csv_files.paths\r\n>>> txt_EMEA_files = text_files['.txt'].select_paths('EMEA', 'isin')\r\n>>> txt_EMEA_files.paths\r\n```\r\n---\r\n\r\n## License\r\n[MIT](LICENSE)\r\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Qomp4ss Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Flexible directory scanner, file path manager, and customizable file loader\u2014all in one",
"version": "0.1.4",
"project_urls": {
"Homepage": "https://github.com/Qomp4ss/file-navigator"
},
"split_keywords": [
"file",
" flexible",
" manager",
" directory",
" scanner",
" path"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "876abe6990171906405da2023443e7add7044ce7a784ddc3286ce180312d1854",
"md5": "ba512faaef8adf3cefdf9da255fb88c6",
"sha256": "aab192285d6890599abd0b17d394106f5331f0874a4a1de1066ab5b2532ed87f"
},
"downloads": -1,
"filename": "file_navigator-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ba512faaef8adf3cefdf9da255fb88c6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 11848,
"upload_time": "2025-01-11T18:32:01",
"upload_time_iso_8601": "2025-01-11T18:32:01.228100Z",
"url": "https://files.pythonhosted.org/packages/87/6a/be6990171906405da2023443e7add7044ce7a784ddc3286ce180312d1854/file_navigator-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a74dc289d293297ced467f334f34aa0bd93280a41667375715ba8566d77d98a6",
"md5": "d925244173bf03b36f748c807e19d496",
"sha256": "c0a41f8975fa9f762012442d21c3dd9943cd35c070728a8c1de19ee2639f7cc9"
},
"downloads": -1,
"filename": "file_navigator-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "d925244173bf03b36f748c807e19d496",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 17383,
"upload_time": "2025-01-11T18:32:03",
"upload_time_iso_8601": "2025-01-11T18:32:03.770593Z",
"url": "https://files.pythonhosted.org/packages/a7/4d/c289d293297ced467f334f34aa0bd93280a41667375715ba8566d77d98a6/file_navigator-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-11 18:32:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Qomp4ss",
"github_project": "file-navigator",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "file-navigator"
}