# Combine CSV Files

Simple desktop tools to:
- combine many CSV files into one file
- filter large datasets and export to CSV/XLSX

Both apps support **English** and **Polish** in the GUI.

## Apps You Can Use

### 1) `combine_csv_gui.py`
Use this when you want to merge multiple CSV files into one output.

What it does:
- reads many CSV files (with encoding/delimiter auto-detection)
- aligns columns to a consistent layout
- can remove duplicates
- exports to CSV or XLSX

### 2) `filter_export_gui_streaming.py`
Use this when you want to filter data, especially very large CSV files.

What it does:
- streams CSV in chunks (memory-friendly)
- filters by:
  - text contains
  - numeric min/max
  - date range
  - location list
  - non-empty phone
- can remove duplicates
- exports to CSV or XLSX

## Install

### Option A: From PyPI (recommended when published)
```bash
pip install combine-csv-files
```

### Option B: From source
```bash
python -m venv .venv
# Windows:
.\.venv\Scripts\activate
# macOS/Linux:
# source .venv/bin/activate

python -m pip install --upgrade pip
pip install -e .
```

## Run the Apps

After install, use:
- `combine-csv-gui`
- `filter-export-streaming`

Or run directly from source:
- `python combine_csv_gui.py`
- `python filter_export_gui_streaming.py`

If GUI is unavailable, both apps fall back to console mode.

## How To Use

### Combine CSV (quick steps)
1. Open `combine_csv_gui.py`.
2. Click **Select input files** and choose your CSV files.
3. Choose output format (`csv` or `xlsx`).
4. Choose where to save output.
5. Start combine and wait for completion message.

### Filter & Export (quick steps)
1. Open `filter_export_gui_streaming.py`.
2. Click **Pick input file**.
3. Set filters you need (leave others empty).
4. Choose output format and destination.
5. Click **Run and export**.

Tip:
- For very large data, use **CSV output** for best performance.

## Main Functions Explained

- **Text filter**: keeps rows where selected column contains the given text.
- **Numeric range**: keeps rows between min and max (inclusive).
- **Date range**: keeps rows between `from` and `to` dates.
- **Remove duplicates**: drops repeated records (full row or selected key columns).
- **Trim spaces in text**: cleans extra spaces before filtering.

## Language Switching

In each GUI app, change language from the **Language** selector:
- `English`
- `Polski`

## Troubleshooting

- **Output file cannot be saved**
  - close the target file in Excel and run again.
- **Wrong characters in CSV**
  - app tries common encodings automatically; if still wrong, re-save source CSV as UTF-8 and retry.
- **Very slow processing**
  - prefer CSV input/output and use `filter_export_gui_streaming.py`.
- **No rows in output**
  - your filters are too strict; clear filters and test again.

## Notes

- `script_runner_history.db` is used by the streaming app to store run history.
- XLSX worksheet password is worksheet protection, not full file encryption.
