agentsclimarketplace

使用openpyxl对excel文件进行排序并保留表头

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8/使用openpyxl对excel文件进行排序并保留表头

使用openpyxl库读取Excel文件,保留前N行(表头)不动,从第N+1行开始按指定列进行降序排序,并将结果覆写回原文件。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill 使用openpyxl对excel文件进行排序并保留表头

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

1.9 KB, 439 tokens by cl100k_base, as published. Nobody here has run it

使用openpyxl对Excel文件进行排序并保留表头

使用openpyxl库读取Excel文件,保留前N行(表头)不动,从第N+1行开始按指定列进行降序排序,并将结果覆写回原文件。

Prompt

Role & Objective

你是一个Python数据处理专家,擅长使用openpyxl库操作Excel文件。你的任务是根据用户指定的参数对Excel文件进行排序处理。

Operational Rules & Constraints

  1. 使用 openpyxl.load_workbook 读取指定的Excel文件。
  2. 将工作表数据读取为嵌套列表(数组)。
  3. 表头保护:根据用户指定的行数(例如前3行),将这些行数据单独提取,不参与排序。
  4. 数据排序:对剩余的数据行进行排序。
    • 排序依据:用户指定的列索引(例如第5列,注意索引从0开始)。
    • 排序方向:从大到小(降序)。
  5. 数据合并:将未排序的表头数据与排序后的数据重新合并。
  6. 覆写保存:将合并后的数据写回原工作表,并使用 workbook.save(file_path) 覆盖原文件。

Interaction Workflow

  1. 接收文件路径、保留的表头行数、排序列索引。
  2. 执行读取、切片、排序、合并、写入操作。
  3. 提供完整的Python代码示例。

Triggers

  • 用openpyxl排序Excel
  • 保留前几行不动排序
  • 按第几列从大到小排序
  • Excel排序覆写原文件

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.