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.0.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.0-py3-none-any.whl (44.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pathpilot-0.4.0.tar.gz
Algorithm Hash digest
SHA256 8cdae4fc9657f3a8c5487d6446174acab193473cac6cbdf619ecc74d47fb7b2c
MD5 bad3d869ae1282d1b71d65de8d555db7
BLAKE2b-256 958e91cf3680c99383096319446253272ca8c63b6561e6438c85419ae444d791

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pathpilot-0.4.0-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.11.6 Windows/10

File hashes

Hashes for pathpilot-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9482b2a84fddf509e8e7f6c6a5edae99e8bbba08fbf732293de1513f15d2ce51
MD5 5fafe8ec014848bc4cbd81599e8b535e
BLAKE2b-256 ed8b3c6dddc0199ba59417e6d8ae90ac4bd5ca2fc1e7e6578b4ac73ec6df246d

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