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.15.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file dirlin-0.1.15.tar.gz
.
File metadata
- Download URL: dirlin-0.1.15.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83707fc684a4be8fecf8e451bda883afeb6d2195f9952cb69ac0e6a4007da5a1 |
|
MD5 | 8594039fc5cc072fb4b8489cc4600b10 |
|
BLAKE2b-256 | 06977f12239cb4c227d93373694a2b4cc913253c94f0d88c91bcd47cb18df9e1 |
File details
Details for the file dirlin-0.1.15-py3-none-any.whl
.
File metadata
- Download URL: dirlin-0.1.15-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63204ed73b1fe7a9ea8413914f7a68562d21ea49e5f722390b7a9688d18bf416 |
|
MD5 | 4555919866afbbed751c6289943a3f45 |
|
BLAKE2b-256 | 8ae31a97914adb64daa59e400f5cb7657314a69fa1482534ec2b887300cd8efe |