Install
openclaw skills install operationCompare two columns in an Excel or CSV file to find differences, unique values, and common values. This skill should be used when the user wants to upload an Excel file and compare two specified columns, find data that exists in one column but not the other, identify common or unique entries between columns, or perform any column-to-column comparison in a spreadsheet.
openclaw skills install operationCompare two specified columns in an Excel/CSV file to identify differences and commonalities between them. The skill produces a formatted Excel report showing values unique to each column, values shared by both, and a summary of the comparison.
Identify from the user's message:
If the user does not specify column identifiers, read the file first to display available columns and ask the user which two to compare.
If the column identifiers are unclear, read the file to show available columns:
import pandas as pd
df = pd.read_excel(input_file, nrows=5)
print(df.columns.tolist())
print(df.head())
Execute the bundled script scripts/compare_columns.py:
python <skill_path>/scripts/compare_columns.py <input_file> <column_a> <column_b> [--sheet <sheet>] [--output <output>] [--mode <mode>]
Parameters:
input_file: Path to the Excel (.xlsx, .xls) or CSV filecolumn_a: Column name (e.g., "姓名"), letter (e.g., A, B), or 0-based indexcolumn_b: Column name, letter, or 0-based index for the second column--sheet: Sheet name or index (default: first sheet)--output: Output file path (default: <input>_comparison_result.xlsx)--mode: Comparison mode:
full (default): Show all categories — only in A, only in B, commondiff: Show only differences (not in both)unique_a: Show only items unique to column Aunique_b: Show only items unique to column Bcommon: Show only items common to both columnsExamples:
# Compare by column names
python scripts/compare_columns.py data.xlsx "姓名" "名字"
# Compare by column letters
python scripts/compare_columns.py data.xlsx A B
# Compare specific sheet, only show differences
python scripts/compare_columns.py data.xlsx "Email" "邮箱" --sheet "Sheet2" --mode diff
# Specify output path
python scripts/compare_columns.py data.xlsx C D --output result.xlsx
After the script runs:
The output Excel file contains the following sheets:
| Sheet | Content |
|---|---|
| Summary | Overview with column names, counts, and statistics |
| Only in [Column A] | Values found only in the first column, with row numbers |
| Only in [Column B] | Values found only in the second column, with row numbers |
| Common Values | Values present in both columns |
Sheets are color-coded: blue for Column A, orange for Column B, green for common values, purple for summary.
pandas and openpyxl if not present.compare_columns.py — Main comparison script that reads an Excel/CSV file, compares two specified columns, and generates a formatted Excel report with the comparison results.