Files
Excel-Filter-Tool/README.md
2026-02-12 09:51:22 +01:00

151 lines
3.3 KiB
Markdown

# Excel Filter Tool
A Python application for filtering Excel files based on regex patterns with both CLI and GUI interfaces.
## Overview
The Excel Filter Tool allows you to:
- Analyze Excel files without opening them
- Filter rows based on configurable regex patterns
- Create new Excel files with filtered data
- Use a graphical interface or command line
- Configure settings via JSON files
## Quick Start
### Windows Users (Recommended)
**Pre-built installer available!**
Download and run `ExcelFilterSetup.exe` from the `dist/` directory for automatic installation including Python and all dependencies.
**OR** use the provided batch files:
- `launch_gui_tkinter.bat` - Launches the Tkinter GUI (recommended)
- `launch_gui.bat` - Launches the PySimpleGUI interface
- `launch_cli.bat` - Launches the command line version
### macOS/Linux Users
```bash
cd excel_filter
pip install -r requirements.txt
python -m src.excel_filter.gui
```
For CLI usage:
```bash
python -m src.excel_filter.main --input input.xlsx --output output.xlsx --pattern "error|warning"
```
### Command Line Usage
```bash
python -m src.excel_filter.main --input input.xlsx --output output.xlsx --pattern "error|warning"
```
### Graphical Interface
```bash
python -m src.excel_filter.gui
```
## Usage Guide
### Basic Filtering
```bash
python -m src.excel_filter.main --input data.xlsx --output filtered.xlsx --pattern "error|warning|critical"
```
### Filter Specific Columns
```bash
python -m src.excel_filter.main --input data.xlsx --output filtered.xlsx --pattern "active" --columns "Status Message"
```
### Using Configuration Files
Create a `config.json` file:
```json
{
"input_file": "input.xlsx",
"output_file": "output_filtered.xlsx",
"pattern": "error|warning|critical",
"sheet_name": "Sheet1",
"columns": ["Status", "Message", "Description"]
}
```
Then run:
```bash
python -m src.excel_filter.main --config config.json
```
## Regex Patterns
The tool uses Python's `re` module. Examples:
- `error|warning` - Match "error" or "warning"
- `^A.*` - Lines starting with "A"
- `\d{3}` - Three-digit numbers
- `[A-Z].*` - Lines starting with capital letter
## Packaging & Distribution
### Build Executable
```bash
pip install pyinstaller pandas openpyxl customtkinter
python build_executable.py
```
### Create Installer
```bash
double-click build_installer.bat
```
This creates `ExcelFilterSetup.exe` that:
- Installs the application as a native Windows executable
- Automatically installs Python and dependencies if needed
- Creates desktop and Start menu shortcuts
## Technical Details
```
### Key Components
- **ExcelFilter Class**: Core filtering functionality
- **CLI Interface**: Command line processing
- **GUI Interface**: Graphical interface
- **Configuration Management**: JSON-based settings
### Dependencies
- `openpyxl` - Excel file operations
- `pandas` - Data manipulation
- `customtkinter` - GUI interface
## Examples
### Filter Log Files
```bash
python -m src.excel_filter.main --input logs.xlsx --output errors.xlsx --pattern "error|warning"
```
### Filter Customer Data
```bash
python -m src.excel_filter.main --input customers.xlsx --output active_customers.xlsx --pattern "active" --columns Status
```
### Filter Numeric Data
```bash
python -m src.excel_filter.main --input sales.xlsx --output high_sales.xlsx --pattern "1000.*" --columns Amount
```