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. It was designed with an emphasis on pandas compatibility to ensure smooth workflows.

Installation

pip install pathpilot

Main Features

  • file_factory ➔ Function that assigns new file instances to the correct child class. Many file types are supported natively including: .xlsx, .csv, .txt, .pickle, etc. The mapping of file extensions to their respective classes is managed using the extension_mapping global dictionary. Unmapped extensions are assigned to the FileBase class.
  • Folder ➔ Class for interacting with folders. It is important to be mindful of the read_only parameter which, if set to True, allows folders to be created or deleted programically.

Example Usage

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

Imports

from pathpilot import Folder, file_factory

Folders

First, we create an instance of the Folder class. Passing read_only=False causes the folder to be created if it does not already exist.

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

Moreover, any subfolders that are referenced while interacting with the folder instance will also be created automatically. Let's use the join method to create a couple subfolders.

# 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 referencing attributes that may or may not already exist.

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

Joining to a file will return a file object instead.

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

Files

First, we 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)
Creating MyFile.xlsx
        writing 72.00 B to 'Sheet1' tab... DONE
        writing 80.00 B to 'Sheet1' tab... DONE

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.3.5.tar.gz (30.2 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.3.5-py3-none-any.whl (36.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pathpilot-0.3.5.tar.gz
Algorithm Hash digest
SHA256 f8efc7c3a4d07a8f946a34d6c23e43765cbbfc8c641e7e290b55c097a26bfde1
MD5 40000707b5a964d82a27098e6746e381
BLAKE2b-256 5dd40a3aa146ed2d2c46e529369194c5478e2f9e6f2f7b2fa6bb4a4f729cb476

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pathpilot-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 36.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.6 Windows/10

File hashes

Hashes for pathpilot-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4e94ca542adeaffa0c54389fddf670f09931f53b777bcfbe673832c830f03c47
MD5 5e0cc1e6ebca9a8e40c568c45bcecd87
BLAKE2b-256 c707be90f63949148c2fc66ab284f31dfb136bada9a25c8e9e7a473e92a2a275

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