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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pathpilot-0.4.2.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.2.tar.gz
Algorithm Hash digest
SHA256 10f820c66a6c4dd9ec2f4cbfa7d425b3e0106dfaa3b16197fe62015daeceb4a7
MD5 c2f24451eb1f213e361c3af429d7c59f
BLAKE2b-256 876766dcf0db2d48c1bdf9a70e0e77053e967db4f715c411d0ea46b6160b614a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pathpilot-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 43.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3f2e15529a53708de3bcc5e90cceee6092a2c610b7360893330088a0e17536d7
MD5 824f4a50f1b11b864dc862b998d62cc4
BLAKE2b-256 c1bc0278fe01698c387e8a61611a592b3b2c8a278773c37f0560bd79990335b6

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