{"data":{"slug":"github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-cell-coloring-duplicate-value-coloring-07f5851d08fd","title":"Excel Conditional Comparison and Large File Processing","summary":"This skill enables users to compare specific coefficients across multiple Excel sheets, identify anomalies, and highlight them in the output report.","url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-cell-coloring-duplicate-value-coloring-07f5851d08fd","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-cell-coloring-duplicate-value-coloring-07f5851d08fd","markdown_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-cell-coloring-duplicate-value-coloring-07f5851d08fd.md","download_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-cell-coloring-duplicate-value-coloring-07f5851d08fd\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"The skill requires Python with pandas and openpyxl installed to extract and compare values from Excel sheets, and to generate a report with red highlighting for anomalies.","instructions":"---\nname: excel-conditional-comparison-and-large-file-processing\ndescription: \"\u5bf9\u6bd4Excel\u591a\u8868\u4e2d\u7684\u7279\u5b9a\u7cfb\u6570\u5e76\u5bf9\u5f02\u5e38\u503c\u8fdb\u884c\u989c\u8272\u6807\u8bb0\u3002\"\n---\n\n# excel-conditional-comparison-and-large-file-processing\n\n> This sub-skill covers one capability of the Excel workflow. For reading\/counting\/Parquet optimization, see the parent workflow SKILL.md.\n\nStep1 \u63d0\u53d6\u4e0d\u540cSheet\u4e2d\u7279\u5b9a\u7ef4\u5ea6\uff08\u5982\u201cB1\u5c42\u201d\uff09\u7684\u6570\u503c\uff0c\u5e76\u8fdb\u884c\u8de8\u8868\u903b\u8f91\u5bf9\u6bd4\u3002\n```python\n# \u5b9a\u4e49\u63d0\u53d6\u903b\u8f91\uff1a\u5b9a\u4f4d\u76ee\u6807\u884c\uff08\u5982\u5305\u542b'B1'\u7684\u884c\uff09\u5e76\u83b7\u53d6\u5176\u5173\u8054\u7684\u7cfb\u6570\ndef extract_target_value(df, target_label='B1', label_col_idx=0, offset_row=1, value_col_idx=2):\n    \"\"\"\n    \u5728\u6307\u5b9a\u5217\u641c\u7d22\u6807\u7b7e\uff0c\u5e76\u8fd4\u56de\u5176\u76f8\u5bf9\u504f\u79fb\u4f4d\u7f6e\u7684\u6570\u503c\n    \"\"\"\n    extracted_values = []\n    for idx, row in df.iterrows():\n        if str(row.iloc[label_col_idx]).strip() == target_label:\n            # \u63d0\u53d6\u76ee\u6807\u884c\u4e0b\u65b9\u6216\u7279\u5b9a\u504f\u79fb\u4f4d\u7f6e\u7684\u6570\u503c\n            if idx + offset_row < len(df):\n                val = df.iloc[idx + offset_row].iloc[value_col_idx]\n                extracted_values.append(val)\n    return extracted_values\n\n# \u5206\u522b\u8bfb\u53d6\u9700\u8981\u5bf9\u6bd4\u7684Sheet\nsheet1_df = pd.read_excel(file_path, sheet_name='Sheet1')\nsheet2_df = pd.read_excel(file_path, sheet_name='Sheet2')\n\n# \u63d0\u53d6\u7cfb\u6570\uff08\u793a\u4f8b\uff1aB1\u5c42\u7684\u6362\u7b97\u7cfb\u6570\uff09\n# \u6ce8\u610f\uff1a\u4e0d\u540cSheet\u7684\u5217\u7d22\u5f15\u53ef\u80fd\u4e0d\u540c\uff0c\u9700\u6839\u636e\u5b9e\u9645\u7ed3\u6784\u8c03\u6574\ns1_coeffs = extract_target_value(sheet1_df, target_label='B1', label_col_idx=1, value_col_idx=3)\ns2_coeffs = extract_target_value(sheet2_df, target_label='B1', label_col_idx=0, value_col_idx=2)\n\n# \u6c47\u603b\u5bf9\u6bd4\u6570\u636e\ncomparison_results = []\ntarget_standard = 0.6 # \u9884\u8bbe\u7684\u6807\u51c6\u9608\u503c\n\nfor val in s1_coeffs:\n    comparison_results.append({'source': 'Sheet1', 'value': val, 'is_anomaly': val != target_standard})\nfor val in s2_coeffs:\n    comparison_results.append({'source': 'Sheet2', 'value': val, 'is_anomaly': val != target_standard})\n```\n\nStep2 \u751f\u6210\u5bf9\u6bd4\u62a5\u544a\uff0c\u5e76\u4f7f\u7528 openpyxl \u5bf9\u5f02\u5e38\u503c\uff08\u975e\u6807\u51c6\u7cfb\u6570\uff09\u8fdb\u884c\u7ea2\u8272\u9ad8\u4eae\u6807\u8bb0\u3002\n```python\nfrom openpyxl import Workbook\nfrom openpyxl.styles import PatternFill\n\noutput_path = 'comparison_report.xlsx'\nwb = Workbook()\nws = wb.active\nws.title = \"Comparison Analysis\"\n\n# \u5199\u5165\u8868\u5934\nheaders = ['\u6570\u636e\u6765\u6e90', '\u63d0\u53d6\u6570\u503c', '\u662f\u5426\u7b26\u5408\u6807\u51c6', '\u72b6\u6001\u6807\u8bb0']\nws.append(headers)\n\n# \u5b9a\u4e49\u7ea2\u8272\u586b\u5145\u6837\u5f0f\nred_fill = PatternFill(start_color='FF0000', end_color='FF0000', fill_type='solid')\n\n# \u904d\u5386\u7ed3\u679c\u5e76\u5199\u5165\uff0c\u540c\u65f6\u5e94\u7528\u6761\u4ef6\u683c\u5f0f\nfor item in comparison_results:\n    status_text = '\u6b63\u5e38' if not item['is_anomaly'] else '\u5f02\u5e38(\u975e0.6)'\n    row_data = [item['source'], item['value'], '\u662f' if not item['is_anomaly'] else '\u5426', status_text]\n    ws.append(row_data)\n    \n    # \u5982\u679c\u662f\u5f02\u5e38\u503c\uff0c\u5c06\u8be5\u884c\u6216\u7279\u5b9a\u5355\u5143\u683c\u6807\u7ea2\n    if item['is_anomaly']:\n        curr_row = ws.max_row\n        for col_idx in range(1, len(headers) + 1):\n            ws.cell(row=curr_row, column=col_idx).fill = red_fill\n\n# \u4fdd\u5b58\u7ed3\u679c\u5e76\u63d0\u4f9b\u4e0b\u8f7d\nwb.save(output_path)\nprint(f\"Analysis complete. Report saved to: {output_path}\")\n```\n","use_cases":["Compare coefficients from different sheets to detect deviations from a standard threshold.","Generate a report with highlighted anomalies for quality control or data validation."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/OpenSenseNova\/SenseNova-Skills\/blob\/07e7ff8c4bdfd7b79e7402fe94af59d2a5a9749b\/skills\/sn-da-excel-workflow\/capability\/excel-cell-coloring\/duplicate-value-coloring\/SKILL.md","source_commit":"07e7ff8c4bdfd7b79e7402fe94af59d2a5a9749b","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T07:27:26.000000Z","updated_at":"2026-11-16T05:16:30.000000Z","seo_title":"Excel Conditional Comparison and Large File Processing","seo_description":"Compare specific coefficients across Excel sheets, identify anomalies, and highlight them in the output report.","seo_keywords":["Excel conditional comparison","Anomaly detection in Excel","Highlight anomalies in Excel","Cross-sheet coefficient comparison","Excel data validation"]}}