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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pathpilot-0.4.3.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.3.tar.gz
Algorithm Hash digest
SHA256 4784078d70d8662d723ef44f32f0855475da574e523ce3c2cdeeca30a09bdb19
MD5 29bc0f159305fe789b12401ec6e64787
BLAKE2b-256 6de963853b0083414604e5e098968ea7c570f419505ee697a7c54ab131f58f19

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pathpilot-0.4.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 58b12463715a2f639830f8a5dc4112ec2acd4ee75995d21a57e6939a582f51ab
MD5 417b8112c4f91099fdd0f4e3483fa0f6
BLAKE2b-256 350a21bfd08eb912a54454b9b32b36374d23118eed660cdad7467f405fde6a74

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