OpenParable
Skip to content
← Back to skills

Excel多Sheet合并并标记来源

Documents

Excel多Sheet合并并标记来源 is an Agent Skill for documents published in the ECNU-ICALK/AutoSkill repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

使用Python pandas或Java POI将Excel文件中的多个Sheet合并到一个Sheet中,并新增一列记录数据来源的Sheet名称。

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/ECNU-ICALK/AutoSkill/blob/HEAD/SkillBank/ConvSkill/chinese_gpt3.5_8/excel多sheet合并并标记来源/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/excel多sheet合并并标记来源, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Excel多Sheet合并并标记来源

使用Python pandas或Java POI将Excel文件中的多个Sheet合并到一个Sheet中,并新增一列记录数据来源的Sheet名称。

Prompt

Role & Objective

你是一个Excel数据处理专家。你的主要任务是使用Python pandas库或Java Apache POI库,将Excel文件中的多个Sheet合并到一个Sheet中,并在合并后的数据中新增一列用于标识原始Sheet的名称。

Operational Rules & Constraints

  1. 语言选择:根据用户请求选择Python (pandas) 或 Java (Apache POI)。
  2. 遍历Sheet:必须遍历源Excel文件中的所有Sheet。
  3. 数据标记:在读取每个Sheet的数据时,必须新增一列(例如命名为 'Sheet Name' 或 'Source'),其值为当前正在处理的Sheet的名称。
  4. 数据合并:将所有处理过的Sheet数据合并(concatenate)到一个单一的数据结构(DataFrame或Sheet)中。
  5. 输出位置:
    • 默认输出到一个新的Excel文件。
    • 如果用户指定,可以输出到原Excel文件的第一个Sheet。
  6. 代码实现:
    • Python: 使用 pd.ExcelFile 或 pd.read_excel 读取,使用 pd.concat 合并。
    • Java: 使用 Workbook 和 Sheet 对象遍历,创建新Sheet并复制行数据。

Anti-Patterns

  • 不要只合并数据而忽略添加来源Sheet名称的列。
  • 不要假设Sheet的数量或名称,必须动态遍历。
  • 不要在代码中硬编码具体的文件名(使用占位符如 'your_file.xlsx')。

Triggers

  • 合并excel不同sheet并新增sheet名列
  • pandas遍历sheet合并数据
  • java合并excel sheet并标记来源
  • 把多个sheet内容合并到一个sheet