Status: MAINTAINED / PAUSE
Purpose: Merge several Excel exports into one clean Excel file.
MergeExcelFiles is a small Python/Tkinter desktop tool for combining multiple Excel files with the same or similar table structure into one output workbook.
The project was originally created for merging exports related to Skyddsvärda träd and other tree-related datasets, including data exported from Artportalen-related workflows. The tool is intentionally generic and can also be used for other Excel files when they share a comparable header/data structure.
- Reads multiple Excel files (
.xlsx,.xlsm,.xls). - Uses a configurable header row. Default: row
3. - Reads data from the rows below the header.
- Removes fully empty rows and columns.
- Merges all rows into one output sheet named
Merged. - Preserves the column order from the first file.
- Adds new columns from later files at the end.
- Optionally adds a source file column for traceability.
- Optionally exports a CSV file next to the Excel output.
The primary use case is merging several Excel exports containing tree-related records, for example:
- Skyddsvärda träd exports.
- Artportalen-related tree observations.
- Similar Excel-based inventories where each file has the same header structure.
This tool does not validate biological records, deduplicate observations, enrich data from APIs, or perform GIS analysis. It only combines tabular Excel data.
Do not commit real working exports to this repository if they contain:
- precise locations,
- protected or sensitive observations,
- personal data,
- internal identifiers,
- non-public project data.
Use only synthetic or clearly sanitized sample files in sample_data/.
MergeExcelFiles/
├── README.md
├── LICENSE
├── requirements.txt
├── .gitignore
├── .gitattributes
├── run_gui.py
├── src/
│ └── merge_excel_files/
│ ├── __init__.py
│ ├── core.py
│ └── gui.py
└── sample_data/
└── README.md
- Python 3.10+
- Tkinter, normally included with standard Python installations on Windows and macOS
- Python packages listed in
requirements.txt
Create a virtual environment:
python -m venv .venvActivate it on Windows PowerShell:
.\.venv\Scripts\Activate.ps1Activate it on macOS/Linux:
source .venv/bin/activateInstall dependencies:
pip install -r requirements.txtpython run_gui.py- Select one or more Excel files.
- Select an output folder.
- Set the header row if needed. Default:
3. - Set a sheet name or sheet index if the data is not in the first sheet.
- Choose whether to add a source file column.
- Choose whether to also save CSV.
- Click Merge and save.
The default setup expects this type of structure:
Row 1: description or metadata, ignored
Row 2: description or metadata, ignored
Row 3: column headers
Row 4+: data rows
The header row can be changed in the GUI.
The tool creates:
- one
.xlsxfile with a sheet namedMerged, - optionally one
.csvfile with the same merged data.
If later files contain columns that were not present in the first file, those columns are added at the end of the output table.
- No duplicate detection.
- No coordinate validation.
- No species/taxon validation.
- No advanced column mapping between differently named fields.
- No command-line interface yet.
- Excel formatting from the input files is not preserved.
Possible future improvements:
- validation report after merge,
- duplicate detection based on selected key columns,
- optional column mapping presets,
- CLI mode for repeatable batch processing,
- automatic output naming with timestamp,
- safer sample data generator.
MIT License. See LICENSE.