Skip to main content

Handy functions for local files

Project description

Dirlin Project

Dirlin is a python script that has some handy tools for dealing with local files.

Some of the use cases include:

  1. Getting the most recently downloaded files into a DataFrame
  2. Finding files with the same naming conventions into a Dataframe
  3. Creating mappings for fast column index-matching

Installation

You can install this project via pip:

pip install dirlin

Uses

This will make it easier to pull files from your local directory to work on different projects.

  1. Import Path and Folder Objects
  2. Define the Helper Object
  3. Create the folder attributes
  4. Define a function to create new folders
# object.py
from dirlin import Path, Folder  # 1 - import path and folder objects

class LocalHelper:  # 2 - defining the Helper Object
    _base_path = Path("path to directory")
    
    DOWNLOADS = Folder(_base_path / "Folder1")  # 3 - creating the folder attributes
    DESKTOP = Folder(_base_path / "Folder2")  # 3 - defining the folder attributes

    @classmethod
    def new_folder(cls, folder: str | Path):  # 4 - defining a function to create new folders
        if isinstance(folder, str):
            folder = Path(folder)
        return Folder(folder)

Getting the most recently downloaded file

from dirlin import Folder, Path

def get_most_recent(filename):
    _base_path = Path("path to directory")
    folder = Folder(_base_path / "Folder1")
    
    df = folder.open_recent(filename)  # returns a dataframe of the most recent file with that pattern
    return df

Combining Multiple Excel documents into a single file

from dirlin import Folder, Path

def get_most_recent(filename):
    _base_path = Path("path to directory")
    folder = Folder(_base_path / "Folder1")
    
    combined_df = folder.find_and_combine(filename_pattern=filename)  # combines documents 
    return combined_df

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

dirlin-0.1.14.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

dirlin-0.1.14-py3-none-any.whl (6.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page