# pathpilot
<div>
[](https://pypi.org/project/pathpilot/)
[](https://github.com/zteinck/pathpilot/blob/master/LICENSE)
</div>
`pathpilot` is a Python package that makes file and folder manipulation simple and intuitive. It was designed with an emphasis on `pandas` compatibility to ensure smooth workflows.
## Installation
```sh
pip install pathpilot
```
## Main Features
- `File` ➔ Function that assigns new file instances to the correct child class. Many file types are supported natively including: *.xlsx*, *.csv*, *.txt*, *.pickle*, etc. The mapping of file extensions to their respective classes is managed using the `extension_mapping` global dictionary. Unmapped extensions are assigned to the `FileBase` class.
- `Folder` ➔ Class for interacting with folders. It is important to be mindful of the `read_only` parameter which, if set to `True`, allows folders to be created or deleted programically.
## Example Usage
Please note the examples below represent a small fraction of the functionality offered by `pathpilot`. Please refer to the documentation within the code for more information.
### Imports
```python
from pathpilot import Folder, File
```
### Folders
First, we create an instance of the `Folder` class. Passing `read_only=False` causes the folder to be created if it does not already exist.
```python
# initiate a folder instance
folder = Folder(r'C:\Users\MyID\Documents\MyFolder', read_only=False)
```
Moreover, any subfolders that are referenced while interacting with the folder instance will also be created automatically. Let's use the `join` method to create a couple subfolders.
```python
# create subfolders (i.e. C:\Users\MyID\Documents\MyFolder\Year\2025\Month\)
month_folder = folder.join('Year', '2025', 'Month')
```
Alternatively, you can access subfolders by referencing attributes that may or may not already exist.
```python
# create a new subfolder called "January" by accessing it via attribute
january_folder = month_folder.january
```
Joining to a file will return a file object instead.
```python
new_years_file = january_folder.join('Happy New Year.txt')
```
### Files
First, we create an instance of the `ExcelFile` class using the `File` function. This occurs automatically by virtue of the `.xlsx` file extension.
```python
# create ExcelFile instance
file = File(r'C:\Users\MyID\Documents\MyFolder\MyFile.xlsx')
```
Next, let's check if the file exists. If not, let's save a `pandas` `DataFrame` as an Excel file.
```python
# export a pd.DataFrame to the file, if it does not already exist
if not file.exists:
df = pd.DataFrame({'id': [1, 2, 3], 'data': ['a', 'b', 'c']})
file.save(df)
```
<pre>
Creating MyFile.xlsx
writing 72.00 B to 'Sheet1' tab... DONE
writing 80.00 B to 'Sheet1' tab... DONE
</pre>
Now let's read the file we created as a `DataFrame`.
```python
# read the file we created as a pd.DataFrame
df = file.read()
```
On second thought, let's delete the file.
```python
# delete the file we created
file.delete()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/zteinck/pathpilot",
"name": "pathpilot",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Zachary Einck",
"author_email": "zacharyeinck@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/a6/6d/f40fb09f9ec15535f040bffc2439bcf4d8f8e3421f29bef8a1d7cc09de48/pathpilot-0.1.8.tar.gz",
"platform": null,
"description": "# pathpilot\n\n<div>\n\n[](https://pypi.org/project/pathpilot/)\n[](https://github.com/zteinck/pathpilot/blob/master/LICENSE)\n\n</div>\n\n`pathpilot` is a Python package that makes file and folder manipulation simple and intuitive. It was designed with an emphasis on `pandas` compatibility to ensure smooth workflows.\n\n\n## Installation\n```sh\npip install pathpilot\n```\n\n\n## Main Features\n- `File` \u2794 Function that assigns new file instances to the correct child class. Many file types are supported natively including: *.xlsx*, *.csv*, *.txt*, *.pickle*, etc. The mapping of file extensions to their respective classes is managed using the `extension_mapping` global dictionary. Unmapped extensions are assigned to the `FileBase` class.\n- `Folder` \u2794 Class for interacting with folders. It is important to be mindful of the `read_only` parameter which, if set to `True`, allows folders to be created or deleted programically.\n\n\n## Example Usage\nPlease note the examples below represent a small fraction of the functionality offered by `pathpilot`. Please refer to the documentation within the code for more information.\n\n### Imports\n```python\nfrom pathpilot import Folder, File\n```\n\n### Folders\nFirst, we create an instance of the `Folder` class. Passing `read_only=False` causes the folder to be created if it does not already exist.\n```python\n# initiate a folder instance\nfolder = Folder(r'C:\\Users\\MyID\\Documents\\MyFolder', read_only=False)\n```\n\nMoreover, any subfolders that are referenced while interacting with the folder instance will also be created automatically. Let's use the `join` method to create a couple subfolders.\n```python\n# create subfolders (i.e. C:\\Users\\MyID\\Documents\\MyFolder\\Year\\2025\\Month\\)\nmonth_folder = folder.join('Year', '2025', 'Month')\n```\n\nAlternatively, you can access subfolders by referencing attributes that may or may not already exist.\n```python\n# create a new subfolder called \"January\" by accessing it via attribute\njanuary_folder = month_folder.january\n```\n\nJoining to a file will return a file object instead.\n```python\nnew_years_file = january_folder.join('Happy New Year.txt')\n```\n\n### Files\nFirst, we create an instance of the `ExcelFile` class using the `File` function. This occurs automatically by virtue of the `.xlsx` file extension.\n```python\n# create ExcelFile instance\nfile = File(r'C:\\Users\\MyID\\Documents\\MyFolder\\MyFile.xlsx')\n```\n\nNext, let's check if the file exists. If not, let's save a `pandas` `DataFrame` as an Excel file.\n```python\n# export a pd.DataFrame to the file, if it does not already exist\nif not file.exists:\n df = pd.DataFrame({'id': [1, 2, 3], 'data': ['a', 'b', 'c']})\n file.save(df)\n```\n<pre>\nCreating MyFile.xlsx\n writing 72.00 B to 'Sheet1' tab... DONE\n writing 80.00 B to 'Sheet1' tab... DONE\n</pre>\n\nNow let's read the file we created as a `DataFrame`.\n```python\n# read the file we created as a pd.DataFrame \ndf = file.read()\n```\n\nOn second thought, let's delete the file.\n```python\n# delete the file we created\nfile.delete()\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Library that facilitates file and folder manipulation in Python.",
"version": "0.1.8",
"project_urls": {
"Homepage": "https://github.com/zteinck/pathpilot",
"Repository": "https://github.com/zteinck/pathpilot"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "01c903a002fa8514e4cb272bf02e7dbb8b805213d3419c734aa6ce68b6f0438e",
"md5": "840fcc6239dad5565587e3d081fa6d53",
"sha256": "fae607e528ae1a6f6ef59cd417f35c45c4ad4c8eccd046825145ac32bc4d271a"
},
"downloads": -1,
"filename": "pathpilot-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "840fcc6239dad5565587e3d081fa6d53",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 33593,
"upload_time": "2024-08-12T05:04:11",
"upload_time_iso_8601": "2024-08-12T05:04:11.238446Z",
"url": "https://files.pythonhosted.org/packages/01/c9/03a002fa8514e4cb272bf02e7dbb8b805213d3419c734aa6ce68b6f0438e/pathpilot-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a66df40fb09f9ec15535f040bffc2439bcf4d8f8e3421f29bef8a1d7cc09de48",
"md5": "3943e4a92add7deb9779906d342a0e26",
"sha256": "648ed70b79cac8fae1a67bd8f85a9097fbbf4c0fe5e70720e44bf199fcfcba34"
},
"downloads": -1,
"filename": "pathpilot-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "3943e4a92add7deb9779906d342a0e26",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 29013,
"upload_time": "2024-08-12T05:04:13",
"upload_time_iso_8601": "2024-08-12T05:04:13.015561Z",
"url": "https://files.pythonhosted.org/packages/a6/6d/f40fb09f9ec15535f040bffc2439bcf4d8f8e3421f29bef8a1d7cc09de48/pathpilot-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-12 05:04:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "zteinck",
"github_project": "pathpilot",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pathpilot"
}