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.1.tar.gz (32.7 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.1-py3-none-any.whl (44.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pathpilot-0.4.1.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.10 Windows/11

File hashes

Hashes for pathpilot-0.4.1.tar.gz
Algorithm Hash digest
SHA256 d2e30a450af46a7cd37314b2a7298fb58c3f1ee52a625aa1c87a0165ca4a9456
MD5 cbe762e60e61880f85a70d806c4e1f9b
BLAKE2b-256 cae8a4a5b6342e04b9de131b96b0e546646eecf0f711ca5512122d65568044f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pathpilot-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 44.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.10 Windows/11

File hashes

Hashes for pathpilot-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bcd6020249fdf7133a46cb5478f2d57903fa565b36bbd35e85ae34a2492ff3dc
MD5 05b6e5535ebc584178a985166b705452
BLAKE2b-256 27f637c84af9b18102fb71da517b7fcfd3c58e57295ba1744c7829d9183a55c8

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