跳到正文
cccskills
免费在 GitHub 公开

excel-conditional-comparison-and-large-file-processing

Extract coefficients associated with a chosen label across Excel sheets and check them against a standard value. Create a comparison workbook showing each value, its source sheet, and red highlighting for rows that fail the check.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

对比Excel多表中的特定系数并对异常值进行颜色标记。

集成工具Excel
查看安装方法

适用场景

  • Check coefficients across multiple Excel sheets
  • Find values that differ from a specified standard
  • Compare sheets with different column layouts
  • Create a report with anomalous rows highlighted in red

包含的文件(1)

  • SKILL.md3.0 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

excel-conditional-comparison-and-large-file-processing

This sub-skill covers one capability of the Excel workflow. For reading/counting/Parquet optimization, see the parent workflow SKILL.md.

Step1 提取不同Sheet中特定维度(如“B1层”)的数值,并进行跨表逻辑对比。

# 定义提取逻辑:定位目标行(如包含'B1'的行)并获取其关联的系数
def extract_target_value(df, target_label='B1', label_col_idx=0, offset_row=1, value_col_idx=2):
    """
    在指定列搜索标签,并返回其相对偏移位置的数值
    """
    extracted_values = []
    for idx, row in df.iterrows():
        if str(row.iloc[label_col_idx]).strip() == target_label:
            # 提取目标行下方或特定偏移位置的数值
            if idx + offset_row < len(df):
                val = df.iloc[idx + offset_row].iloc[value_col_idx]
                extracted_values.append(val)
    return extracted_values

# 分别读取需要对比的Sheet
sheet1_df = pd.read_excel(file_path, sheet_name='Sheet1')
sheet2_df = pd.read_excel(file_path, sheet_name='Sheet2')

# 提取系数(示例:B1层的换算系数)
# 注意:不同Sheet的列索引可能不同,需根据实际结构调整
s1_coeffs = extract_target_value(sheet1_df, target_label='B1', label_col_idx=1, value_col_idx=3)
s2_coeffs = extract_target_value(sheet2_df, target_label='B1', label_col_idx=0, value_col_idx=2)

# 汇总对比数据
comparison_results = []
target_standard = 0.6 # 预设的标准阈值

for val in s1_coeffs:
    comparison_results.append({'source': 'Sheet1', 'value': val, 'is_anomaly': val != target_standard})
for val in s2_coeffs:
    comparison_results.append({'source': 'Sheet2', 'value': val, 'is_anomaly': val != target_standard})

Step2 生成对比报告,并使用 openpyxl 对异常值(非标准系数)进行红色高亮标记。

from openpyxl import Workbook
from openpyxl.styles import PatternFill

output_path = 'comparison_report.xlsx'
wb = Workbook()
ws = wb.active
ws.title = "Comparison Analysis"

# 写入表头
headers = ['数据来源', '提取数值', '是否符合标准', '状态标记']
ws.append(headers)

# 定义红色填充样式
red_fill = PatternFill(start_color='FF0000', end_color='FF0000', fill_type='solid')

# 遍历结果并写入,同时应用条件格式
for item in comparison_results:
    status_text = '正常' if not item['is_anomaly'] else '异常(非0.6)'
    row_data = [item['source'], item['value'], '是' if not item['is_anomaly'] else '否', status_text]
    ws.append(row_data)
    
    # 如果是异常值,将该行或特定单元格标红
    if item['is_anomaly']:
        curr_row = ws.max_row
        for col_idx in range(1, len(headers) + 1):
            ws.cell(row=curr_row, column=col_idx).fill = red_fill

# 保存结果并提供下载
wb.save(output_path)
print(f"Analysis complete. Report saved to: {output_path}")

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Compare counts and shares for two categories in Excel data. The skill cleans the selected columns, calculates differences and percentages, and produces a summary spreadsheet plus bar and pie charts.

中文简介正在准备中。当前显示英语简介。

  • Comparing counts for two categories
  • Visualizing category shares
  • Cleaning merged-cell data before counting
OpenSenseNova/SenseNova-Skills57992026年10月9日 更新

Analyze Excel data using custom categories, count distributions, and compare groups with charts. Score text using its length, technical terms, numbers, and selected complex concepts, then visualize difficulty levels and the relationship between text length and scores.

中文简介正在准备中。当前显示英语简介。

  • Summarize Excel records using custom categories
  • Compare category distributions across groups
  • Score and grade text using adjustable rules
OpenSenseNova/SenseNova-Skills57992026年10月9日 更新

Count categories in a chosen data column after removing missing values and placeholder labels. Calculate each category’s share and create high-resolution charts combining counts, percentages, pie charts, and horizontal bars for distribution reports.

中文简介正在准备中。当前显示英语简介。

  • Compare record counts across categories
  • Show category shares with pie and bar charts
  • Exclude placeholder labels before counting
OpenSenseNova/SenseNova-Skills57992026年10月9日 更新

Clean category and numeric fields in structured data, compare groups with counts and cross-tabulations, and produce charts, Excel results, and a Markdown report. Export visuals as high-resolution PNG and SVG files for use in reports.

中文简介正在准备中。当前显示英语简介。

  • Compare category distributions across groups
  • Clean category labels and fill merged-cell gaps
  • Export analysis results to Excel
OpenSenseNova/SenseNova-Skills57992026年10月9日 更新

Filter Excel data using candidate column names, RGB color values, text prefixes, and regular expressions, which match text patterns. Calculate totals and averages, then export results to Excel with highlighted rows and a download link.

中文简介正在准备中。当前显示英语简介。

  • Filtering rows by RGB values or identifier prefixes
  • Converting text to numbers and calculating totals or averages
  • Extracting matching commands with their identifiers and descriptions
OpenSenseNova/SenseNova-Skills57992026年10月9日 更新

Filter rows from Excel or previously converted Parquet files, a format designed for efficient data storage. Summarize matching records by group with counts, percentages, and totals, then export the summary to Excel.

中文简介正在准备中。当前显示英语简介。

  • Count records containing a specified risk level by work category
  • Calculate group shares among matching records
  • Summarize large datasets already converted to Parquet
OpenSenseNova/SenseNova-Skills57992026年10月9日 更新

查看 OpenSenseNova 的全部技能

报告此技能的问题