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.17.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

dirlin-0.1.17-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file dirlin-0.1.17.tar.gz.

File metadata

  • Download URL: dirlin-0.1.17.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for dirlin-0.1.17.tar.gz
Algorithm Hash digest
SHA256 e1a8551108f64a4a3be0d2b6c1ba8246778454f3d38b0cd8ad11ad36f72070dc
MD5 6b7e60ef9f2339edf28f671e4ce6f128
BLAKE2b-256 06d5a28e5983fb191e4bc4e768b21839e9b2e96731f6ef197613a856ea44c8d2

See more details on using hashes here.

File details

Details for the file dirlin-0.1.17-py3-none-any.whl.

File metadata

  • Download URL: dirlin-0.1.17-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for dirlin-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 60bdf431e61617f765bcdfb0b14fa09296ba2db1e982773fe9092d8f3abfdf71
MD5 4d1ffb82eec539632cf080c9270d915a
BLAKE2b-256 bbf8f9500c73ee7d8a4b501b1fbcd61a354121a76065053c2a8980a08c4fc429

See more details on using hashes here.

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