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:
- Getting the most recently downloaded files into a DataFrame
- Finding files with the same naming conventions into a Dataframe
- 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.
- Import Path and Folder Objects
- Define the Helper Object
- Create the folder attributes
- 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
Release history Release notifications | RSS feed
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)