动态统计多Sheet Excel文件行数以判断大文件处理逻辑,并根据特定条件筛选数据、重命名字段后导出为包含下载链接的新Excel文件,适用于多Sheet数据探查与条件过滤导出场景。
npx skills add https://github.com/OpenSenseNova/SenseNova-Skills --skill excel-sheet-filter-export
> This sub-skill covers one capability of the Excel workflow. For reading/counting/Parquet optimization, see the parent workflow SKILL.md.
Step1 读取目标Sheet,清理字段格式并根据特定条件筛选记录,统计关键指标。
target_sheet = 'Sheet1' # 替换为实际sheet名
df_target = pd.read_excel(file_path, sheet_name=target_sheet)
# 清理目标列的字符串格式(去除首尾空格)
filter_col = 'group_col'
if filter_col in df_target.columns:
df_target[filter_col] = df_target[filter_col].astype(str).str.strip()
# 筛选符合条件的记录
target_value = 'target_value_example'
mask = df_target[filter_col] == target_value
df_filtered = df_target[mask]
# 统计特定范围的种类数量
target_col = 'target_col'
if target_col in df_filtered.columns:
specific_ranges = df_filtered[target_col].dropna().unique()
print(f"{target_col} 种类数量:", len(specific_ranges))
# 统计各分类数量与占比
value_counts_df = df_filtered[target_col].value_counts().reset_index()
value_counts_df.columns = [target_col, '数量']
value_counts_df['占比'] = (value_counts_df['数量'] / value_counts_df['数量'].sum()).map('{:.2%}'.format)
# 添加总计行
total_row = pd.DataFrame({
target_col: ['总计'],
'数量': [value_counts_df['数量'].sum()],
'占比': ['100.00%']
})
value_counts_df = pd.concat([value_counts_df, total_row], ignore_index=True)
print(f"\n{target_col} 分布情况:\n", value_counts_df.head())
Step2 提取所需字段,对结果进行字段重命名与格式化处理,保存为新的Excel文件并生成下载链接。
# 提取需要的列并重命名
selected_cols = ['col1', 'col2', filter_col, target_col]
# 确保列存在
existing_cols = [col for col in selected_cols if col in df_filtered.columns]
result_df = df_filtered[existing_cols].copy()
# 字段重命名映射字典
rename_mapping = {
'col1': '重命名列1',
'col2': '重命名列2',
filter_col: '筛选维度',
target_col: '分析维度'
}
result_df = result_df.rename(columns=rename_mapping)
# 保存结果并提供下载链接
output_path = "filtered_result_output.xlsx"
result_df.to_excel(output_path, index=False)
print("结果已保存至:", output_path)
print(f"[下载结果文件](sandbox:{output_path})")
Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like \"the xlsx in my downloads\") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.
Picks random winners from lists, spreadsheets, or Google Sheets for giveaways, raffles, and contests. Ensures fair, unbiased selection with transparency.
Query openFDA API for drugs, devices, adverse events, recalls, regulatory submissions (510k, PMA), substance identification (UNII), for FDA regulatory data analysis and safety research.
MATLAB and GNU Octave numerical computing for matrix operations, data analysis, visualization, and scientific computing. Use when writing MATLAB/Octave scripts for linear algebra, signal processing, image processing, differential equations, optimization, statistics, or creating scientific visualizations. Also use when the user needs help with MATLAB syntax, functions, or wants to convert between MATLAB and Python code. Scripts can be executed with MATLAB or the open-source GNU Octave interpreter.
UMAP dimensionality reduction. Fast nonlinear manifold learning for 2D/3D visualization, clustering preprocessing (HDBSCAN), supervised/parametric UMAP, for high-dimensional data.
Creating interactive data visualisations using d3.js. This skill should be used when creating custom charts, graphs, network diagrams, geographic visualisations, or any complex SVG-based data visualisation that requires fine-grained control over visual elements, transitions, or interactions. Use this for bespoke visualisations beyond standard charting libraries, whether in React, Vue, Svelte, vanilla JavaScript, or any other environment.
Access AlphaFold 200M+ AI-predicted protein structures. Retrieve structures by UniProt ID, download PDB/mmCIF files, analyze confidence metrics (pLDDT, PAE), for drug discovery and structural biology.
Take opensensenova/excel-sheet-filter-export from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.