Skip to main content

Library that facilitates file and folder manipulation in Python.

Project description

pathpilot

Package version License

pathpilot is a Python package that makes file and folder manipulation simple and intuitive.

Installation

pip install pathpilot

Main Features

  • file_factory → Function that routes new file instances to the appropriate child class. Some file types are supported natively such as: .xlsx, .csv, .txt, .parquet, etc. The mapping of file extensions to their child class counterparts is managed using the config.extension_mapping dictionary. Unmapped extensions are routed to the File base class by default.
  • Folder → Class that handles folder operations. It is important to be mindful of the read_only parameter which, if True, allows folders to be created or deleted.

Example Usage

Please note the examples below represent a small fraction of the functionality offered by pathpilot. Please refer to the intra-code documentation more information.

Imports

from pathpilot import Folder, file_factory

Folders

Create a Folder instance. Passing read_only=False will create the folder if it does not already exist.

# initiate a folder instance
folder = Folder(r'C:\Users\MyID\Documents\MyFolder', read_only=False)

The join method is used to access subfolders. If read_only=False, the subfolders are created automatically.

# 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 attribute.

# create a new subfolder called "January" by accessing it via attribute
january_folder = month_folder.january

Joining to a file name will return a file object instead.

new_years_file = january_folder.join('Happy New Year.txt')

Files

Create an instance of the ExcelFile class using the file_factory function. This occurs automatically by virtue of the .xlsx file extension.

# create ExcelFile instance
file = file_factory(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.

# 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)
MyFile.xlsx:
    • Wrote 72.00 B to sheet 'Sheet1' in 0.0 seconds.
    • Wrote 80.00 B to sheet 'Sheet1' in 0.0 seconds.

Now let's read the file we created as a DataFrame.

# read the file we created as a pd.DataFrame
df = file.read()

On second thought, let's delete the file.

# delete the file we created
file.delete()

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

pathpilot-0.4.5.tar.gz (50.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pathpilot-0.4.5-py3-none-any.whl (43.9 kB view details)

Uploaded Python 3

File details

Details for the file pathpilot-0.4.5.tar.gz.

File metadata

  • Download URL: pathpilot-0.4.5.tar.gz
  • Upload date:
  • Size: 50.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pathpilot-0.4.5.tar.gz
Algorithm Hash digest
SHA256 67ac41eec2b5005f45ccd90181377c82a7169dfaa297af3b45a0b76160f8c8e5
MD5 e11819521eda086887bf0f9c56cbad3e
BLAKE2b-256 0af7bb2c57f7690aeb5e6b204861578f96a7985b22127386c86b14c22bf3e2a2

See more details on using hashes here.

File details

Details for the file pathpilot-0.4.5-py3-none-any.whl.

File metadata

  • Download URL: pathpilot-0.4.5-py3-none-any.whl
  • Upload date:
  • Size: 43.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pathpilot-0.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7c2eb7d1a7904d7f8554f66c4749dad804bd94da61e7c0d20076bfa88c3ac34b
MD5 df51c33ad46f35bfe5097e4a0e54d089
BLAKE2b-256 491e98269bc5824ef8d4990e26e1a9b68f254d20746231059848476f889f542d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page