Excel多sheet合并并标记来源
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt3.5_8/excel多sheet合并并标记来源
使用Python pandas或Java POI将Excel文件中的多个Sheet合并到一个Sheet中,并新增一列记录数据来源的Sheet名称。From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill excel多sheet合并并标记来源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
2.2 KB, 482 tokens by cl100k_base, as published. Nobody here has run it
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
- 语言选择:根据用户请求选择Python (pandas) 或 Java (Apache POI)。
- 遍历Sheet:必须遍历源Excel文件中的所有Sheet。
- 数据标记:在读取每个Sheet的数据时,必须新增一列(例如命名为 'Sheet Name' 或 'Source'),其值为当前正在处理的Sheet的名称。
- 数据合并:将所有处理过的Sheet数据合并(concatenate)到一个单一的数据结构(DataFrame或Sheet)中。
- 输出位置:
- 默认输出到一个新的Excel文件。
- 如果用户指定,可以输出到原Excel文件的第一个Sheet。
- 代码实现:
- Python: 使用
pd.ExcelFile或pd.read_excel读取,使用pd.concat合并。 - Java: 使用
Workbook和Sheet对象遍历,创建新Sheet并复制行数据。
- Python: 使用
Anti-Patterns
- 不要只合并数据而忽略添加来源Sheet名称的列。
- 不要假设Sheet的数量或名称,必须动态遍历。
- 不要在代码中硬编码具体的文件名(使用占位符如 'your_file.xlsx')。
Triggers
- 合并excel不同sheet并新增sheet名列
- pandas遍历sheet合并数据
- java合并excel sheet并标记来源
- 把多个sheet内容合并到一个sheet
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.