point-compare compares two worksheets inside one Excel workbook for CMM / industrial measurement workflows.
Supported logical fields are Name, X, Y, Z, I, J, K.
The main output is a new Excel file with styled comparison reports and updated original sheet with status buckets:
MATCH— name and coordinates matchNAME_CHANGED— same coordinates, different nameCOORD_CHANGED— same name, different coordinatesREPLACED?— original point deleted and replaced by nearby new pointDELETED— point exists only in originalADDED— point exists only in new sheet
compare_points_gui.py— primary entry point; Tkinter desktop GUI that loads workbook, selects two sheets, runs comparison, displays summary, and creates new output filecompare_points_v3.py— batch/config-driven Python variant for automationComparePoints_v3.bas— Excel VBA implementationrun_point_compare_gui.bat— Windows launcher for the GUIPointsCompare_Template.xlsx— workbook template with sample datapoint_compare/— shared library package (schema, core, styles, validators, excel_io)archived/— legacy interactive CLI (no longer used)README.md— quick-start and behavior summary
All implementations use the shared point_compare library:
- Read two source sheets from one Excel workbook.
- Require exact source headers
Name/X/Y/Z/I/J/Kon both sheets. - Normalize columns into canonical fields via
prepare_sheet(). - Run
compare()function (core.py):- Build name lookup from new dataset
- Build coordinate buckets using tolerance-quantized keys
- For each original row: match by name first, then by coordinate key, else mark as
DELETED - Unmatched new rows become
ADDED
- Run
link_moved_pairs()to identify DELETED+ADDED pairs withinclose_points_tol:- If a DELETED has a nearby ADDED within tolerance, both are marked as
REPLACED? - Populates
NEW_*and difference columns on DELETED rows
- If a DELETED has a nearby ADDED within tolerance, both are marked as
- Copy original workbook to new output file with timestamp:
filename_CMP_YYYYMMDD_HHMMSS.xlsx - Append comparison results to original sheet:
- Insert row 1 if needed for group labels
- Write
STATUS,NEW_Name/X/Y/Z/I/J/K, and*_diffcolumns after source data - Append unmatched new points as extra rows with
STATUS = NEW
- Create optional
CMP_*report sheets (when enabled)
Output File: New file created; original workbook is never modified.
Comparison Parameters:
tol— XYZ coordinate tolerance (mm)ijk_tol— I/J/K toleranceuse_ijk— include I/J/K in coordinate matchingclose_points_tol— distance threshold for REPLACED? linking (default 10 mm, independent oftol)create_report_sheets— enableCMP_*report sheet generation
Report Sheets (when enabled):
CMP_Overview— summary countsCMP_All Results— all points with statusCMP_Match/CMP_Name Changed/CMP_Coord Changed/CMP_Replaced/CMP_Deleted/CMP_Added— filtered viewsCMP_Close Points— ALL original/new pairs withinclose_points_tolwith status and 3D distanceCMP_Nearest Points— for each original point, its single nearest new point
Color Scheme (openpyxl PatternFill):
MATCH— light blue/gray themeNAME_CHANGED,COORD_CHANGED,REPLACED?— yellow (unified "changed" indication)DELETED— redADDED/NEW— orange
Original Sheet Writeback:
- Shifts headers down to row 2, inserts grouped labels in row 1:
Original data,Comparison status,New Data,Difference - Preserves existing colors in source area
- Clears active AutoFilter before writing
- Uses source sheet's font family
- Displays coordinates with
0.000formatting - Difference columns (
*_diff) highlighted in orange bold when non-zero
Edge Cases:
- Hidden Excel query tables are normalized to regular tables; external data names are stripped
- Sheet names with hidden leading/trailing spaces are resolved via unique trim-matches
- Duplicate names in new dataset: last match wins (name lookup dictionary behavior)
__init__.py— package markerschema.py— constants (DEFAULTS, PALETTE, STATUS_LABEL, STATUS_FILLS, field definitions, report naming)core.py— comparison logic (compare(),link_moved_pairs(),build_close_points_report(),build_nearest_points_report())validators.py— input validation (validate_workbook(),list_sheets())styles.py— formatting utilities (StyleKit, cell styling functions)excel_io.py— workbook I/O (read_sheet(),prepare_sheet(),run_comparison(),write_data_sheet(),write_report_sheets())
All implementations (GUI, batch, potential future tools) import from this shared library to ensure consistency.
- Duplicate point names in the new dataset: last match wins (name lookup dictionary behavior).
- No local automated test fixtures yet.
- VBA implementation (
ComparePoints_v3.bas) has not been updated to match recent Python changes (REPLACED? status, output-file mode). - Original workbook is never modified; user must manage old comparison files manually.
- Refactored into shared library (
point_compare/package) to eliminate code duplication across CLI, GUI, and batch modes - Output file mode: Comparison creates new timestamped file instead of modifying original workbook
- REPLACED? status: New status category for DELETED+ADDED pairs within
close_points_tol; handled by fixedlink_moved_pairs()logic - Fixed index-mapping bug in
link_moved_pairs(): now uses ORIG_/NEW_ values directly from df_all instead of error-prone position math - Unified colors: REPLACED?, COORD_CHANGED, NAME_CHANGED now all use yellow (same visual category)
- Archived CLI: Interactive script moved to
archived/(GUI is now primary user-facing entry point)
- Add automated test fixtures for all six comparison categories (MATCH, NAME_CHANGED, COORD_CHANGED, REPLACED?, DELETED, ADDED)
- Implement duplicate-name error/warning to surface lossy behavior
- Update VBA implementation to match current Python status categories and output-file behavior
- Add batch-mode tests for concurrent workbook processing