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.16.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file dirlin-0.1.16.tar.gz
.
File metadata
- Download URL: dirlin-0.1.16.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 | 08d61175e1d60abcc0a9b76ce8d9ab0985ca5afa5c3a9b5ad8d91b6986d48a8c |
|
MD5 | bae97b45fd7b366b15a3d1cd8b187a32 |
|
BLAKE2b-256 | b625cedb469c1cd5b9718e20e7a378c87487c4cd88fe7e3dd456a0e55cf7345c |
File details
Details for the file dirlin-0.1.16-py3-none-any.whl
.
File metadata
- Download URL: dirlin-0.1.16-py3-none-any.whl
- Upload date:
- Size: 7.0 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 | 19de6d3e8daf1ab56e05205c5a3f4d8047cfaa0a92185b8764df2fc1ab52787a |
|
MD5 | d28abe3018d8b179bbacb91c47c5b1a5 |
|
BLAKE2b-256 | 131074e3ac25be699317c41251bc8c09112962fbcbffa030e1f34a459173682f |