Simple file discovery and Excel processing toolkit for document workflows
Project description
๐ filekit
Simple file discovery and Excel processing toolkit.
Find files by type โ Copy/Move โ Process Excel โ Get DataFrame
๐ Quick Start
Installation
pip install filekit-ljd
Basic Usage
from filekit import find, ops
# Find the latest Manpower Budget file from predefined paths
file = find.manpower_budget()
# Copy to a local backup folder
backup = file.copy(r"C:\Temp\Backup")
# Process the Excel sheet and get a clean DataFrame
df = ops.clean_sheet(file, sheet="Sheet1", output=r"C:\Temp\result.xlsx")
print(df.head())
โจ Features
- Smart file discovery โ finds the most recent file of a given type from predefined folder lists
- Type-aware sorting โ each file type uses its own versioning/date logic (revision numbers, months, quarters)
- Fluent file operations โ chainable
.copy()and.move()that return newFileObjectinstances - Excel merged-cell expansion โ flattens merged cells into a normalized
Datos_Limpiossheet before reading - Pandas integration โ every Excel processing call returns a
pd.DataFrameready for analysis - Progress feedback โ large Excel files show a
tqdmprogress bar automatically - Graceful not-found handling โ
FileObjectevaluates toFalsewhen no file is found, soif file:checks just work
๐ฆ Installation
pip install filekit-ljd
Requirements
| Package | Minimum version |
|---|---|
| Python | 3.10+ |
| openpyxl | 3.1.5+ |
| pandas | 3.0.2+ |
| tqdm | 4.67.3+ |
๐ API Documentation
find โ File Discovery
Import the singleton namespace:
from filekit import find
All methods search the predefined paths in paths_config.py and return a FileObject.
| Method | Searches for |
|---|---|
find.manpower_budget() |
Latest Manpower Budget file (sorted by revision + month) |
find.manpower_documents() |
Latest Manpower Documents file (sorted by year, month, quarter) |
find.manpower() |
Latest general Manpower file (sorted by month + day) |
find.zj() |
Latest ZJ production file (sorted by date + version) |
find.real_time_production() |
Latest Real-Time Production file |
FileObject โ File Wrapper
FileObject wraps the path returned by find.*() and exposes file operations.
file = find.manpower_budget()
# Check if a file was found
if file:
print(f"Found: {file}") # str(file) โ full path string
# Copy to a destination folder (creates folders as needed)
backup = file.copy(r"C:\Backup") # โ FileObject pointing to the copy
# Move to a destination folder
archived = file.move(r"C:\Archive") # โ FileObject pointing to the new location
| Method / Usage | Description |
|---|---|
str(file) |
Returns the full file path as a string |
bool(file) |
True if a file was found, False otherwise |
file.copy(destination) |
Copies file to destination/ and returns a new FileObject |
file.move(destination) |
Moves file to destination/ and returns a new FileObject |
copy()andmove()are chainable โ both return aFileObjectso you can keep operating on the result.
ops โ Excel Processing
Import the singleton namespace:
from filekit import ops
ops.clean_sheet(file, sheet, output)
Expands merged cells in an Excel sheet and returns a pd.DataFrame.
df = ops.clean_sheet(
file, # FileObject, str, or Path
sheet="Sheet1", # Sheet name to process (default: "Sheet1")
output=None, # Optional output path
)
| Parameter | Type | Description |
|---|---|---|
file |
FileObject | str | Path |
Source Excel file |
sheet |
str |
Sheet name to read (default "Sheet1") |
output |
str | Path | None |
If given, saves a new file with only the cleaned sheet; if None, overwrites the original |
Returns: pd.DataFrame โ first row used as column headers.
If
sheetdoes not exist, the processor automatically falls back to the first sheet whose name contains"sheet"(case-insensitive).
Low-level utilities
These are used internally but can be imported for custom workflows:
from filekit.fileSelector import find_in_folder
from filekit.scanNameFiles import identify_file_type, get_file_info
from filekit.core.clean_sheet import CleanSheetProcessor, clean_sheet
find_in_folder(folder_path, file_type)
Searches a single folder for the most recent file of the given type.
path = find_in_folder(r"C:\Reports", "MANPOWER_BUDGET")
# Returns: str path or None
identify_file_type(file_path)
Identifies the type of a file based on its name alone.
identify_file_type("Manpower budget 2026 Rev 3.xlsx") # โ "MANPOWER_BUDGET"
identify_file_type("ZJ26042804-8170.xlsx") # โ "ZJ"
identify_file_type("Real-Time Production May.xlsx") # โ "REAL_TIME_PRODUCTION"
CleanSheetProcessor โ step-by-step processing
Low-level class for fine-grained control over the Excel processing pipeline:
from filekit.core.clean_sheet import CleanSheetProcessor
processor = CleanSheetProcessor(ruta="data.xlsx", nombre_hoja_origen="Sheet1")
processor.abrir()
processor.aplanar_merged_cells()
processor.guardar(ruta_salida="output.xlsx")
df = processor.obtener_dataframe()
๐๏ธ Project Structure
filekit/
โโโ finder/
โ โโโ simple.py # find API โ locates files by type from predefined paths
โโโ operations/
โ โโโ simple.py # ops API โ Excel processing operations
โโโ core/
โ โโโ file.py # FileObject โ wraps paths with copy/move operations
โ โโโ clean_sheet.py # CleanSheetProcessor โ expands merged cells, returns DataFrame
โโโ fileSelector.py # find_in_folder โ single-folder file search
โโโ scanNameFiles.py # identify_file_type โ name-based type detection
โโโ validators.py # Format validators for ZJ, Manpower subtypes
โโโ paths_config.py # DEFAULT_PATHS โ predefined search directories
Module responsibilities
| Module | Responsibility |
|---|---|
finder/ |
Orchestrates search across all predefined paths for a given type |
operations/ |
High-level Excel processing, returns DataFrame |
core/file.py |
Chainable file copy/move wrapper |
core/clean_sheet.py |
Merged-cell expansion and DataFrame extraction |
fileSelector.py |
Single-folder search, delegates type detection to scanNameFiles |
scanNameFiles.py |
Identifies file type from filename patterns |
validators.py |
Validates ZJ format (ZJ{YYMMDD}{DD}-{version}) and Manpower subtypes |
paths_config.py |
Central dictionary of per-type search directories |
๐ก Examples
Example 1 โ Basic file discovery
from filekit import find
file = find.manpower_budget()
if file:
print(f"Found: {file}")
else:
print("No Manpower Budget file found in configured paths.")
Example 2 โ Copy and process in one chain
from filekit import find, ops
file = find.manpower_budget()
# Copy to a working directory, then process the copy
working_copy = file.copy(r"C:\Work\Temp")
df = ops.clean_sheet(working_copy, sheet="Sheet1")
print(f"Rows: {len(df)}, Columns: {len(df.columns)}")
print(df.head())
Example 3 โ Save cleaned Excel and get DataFrame
from filekit import find, ops
file = find.zj()
df = ops.clean_sheet(
file,
sheet="Data",
output=r"C:\Reports\ZJ_clean.xlsx", # saves a new file with only the clean sheet
)
# Continue analysis
summary = df.groupby("Line").sum()
Example 4 โ Operation chaining
from filekit import find, ops
# Find โ archive the original โ process the archive
df = ops.clean_sheet(
find.manpower().move(r"C:\archive"),
sheet="Sheet1",
output=r"C:\processed\manpower_clean.xlsx",
)
Example 5 โ Custom folder search (no predefined paths)
from filekit.fileSelector import find_in_folder
from filekit.core.file import FileObject
from filekit import ops
path = find_in_folder(r"C:\MyReports", "MANPOWER_BUDGET")
if path:
file = FileObject(path)
df = ops.clean_sheet(file, sheet="Budget")
โ๏ธ Configuration
Predefined Paths
Edit filekit/paths_config.py to configure which folders each file type searches:
DEFAULT_PATHS = {
"MANPOWER_BUDGET": [
r"\\server\share\Manpower\Budget 2026",
r"\\server\share\Manpower\Budget 2025", # fallback
],
"MANPOWER": [
r"\\server\share\Manpower",
],
"ZJ": [
r"\\server\share\Production\ZJ",
],
"MANPOWER_DOCUMENTS": [
r"\\server\share\Manpower\Documents",
],
"REAL_TIME_PRODUCTION": [
r"\\server\share\Production\RealTime",
],
}
- Each key maps to a list of folders โ tried in order, search stops at the first folder that yields a match.
- Types not present in
DEFAULT_PATHSwill return an emptyFileObjectfromfind.*().
๐ Supported File Types
| Type key | Identified by | Latest-file logic |
|---|---|---|
MANPOWER_BUDGET |
"MANPOWER" + "BUDGET" in filename |
Highest revision number, then month |
MANPOWER_DOCUMENTS |
"MANPOWER" + "DOCUMENTS" in filename |
Latest year, then month, then quarter |
MANPOWER |
"MANPOWER" (no Budget/Documents) |
Latest month + day |
ZJ |
Starts with "ZJ", format ZJ{YYMMDD}{DD}-{version} |
Latest date, then version number |
REAL_TIME_PRODUCTION |
"REAL-TIME" + "PRODUCTION" in filename |
First match (single expected file) |
ZJ format example:
ZJ26042804-8170.xlsxโ date260428(YYMMDD), version prefix04, version8170.
Files with(1),(2)suffixes are treated as duplicates and sorted accordingly.
๐ License
MIT License โ see LICENSE for details.
๐ค Author
LJD-UwU
- Email: himexpe.interns@hisense.com
- GitHub: https://github.com/LJD-UwU
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file filekit_ljd-0.1.1.tar.gz.
File metadata
- Download URL: filekit_ljd-0.1.1.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaa8deaf8fc9b783a1a1e43878228eb498a214e608fa8566858f1777910d406b
|
|
| MD5 |
57ffa9a765a1ef76ef65385e5beb866c
|
|
| BLAKE2b-256 |
5f9d2f2229a3016e5e9a2ac86e48f605346623a9155795a44326a3df703dd884
|
File details
Details for the file filekit_ljd-0.1.1-py3-none-any.whl.
File metadata
- Download URL: filekit_ljd-0.1.1-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95173fc9822e7d132ecdc6db7295acac9802d191c409bc91018bebc930889dcf
|
|
| MD5 |
a08302ffcf4ac3332e22ebdac72bc6ed
|
|
| BLAKE2b-256 |
fe7d80d2ee8f521dea846dd80d3a065c57eeae2103eb19fd56283378c56e8d85
|