Repository navigation
Conversation
在 contributors/my12yyds/ 下新增以下方法,均带完整参数/返回值注释与单元测试: - excel_diff:比对两份 Excel,支持按位置或按主键比对,可导出差异表 - excel_dedupe:按指定列或整行去重,返回重复行与保留行的对应关系 - excel_column_stats:逐列统计填充率、类型、唯一值数量与数值分布 - excel2json:工作表转 JSON,支持 records / columns / values 三种结构 - excel2csv:工作表导出 CSV,默认 utf-8-sig 解决中文乱码,支持多表批量 配套改动: - 新增 39 个单元测试(contributors/my12yyds/test_excel_toolkit.py) - 按约定在 skills/excel/<方法>/ 下补充 5 个 Skill 包装与 SKILL.md - 新增 contributors/my12yyds/DECLARATION.md,声明作者、维护范围、许可与边界 - skills/excel/__init__.py 追加 5 个导出(仅新增,未改动既有条目) 未改动 office/ 等核心目录,对既有代码无行为影响。
CoderWanFeng
pushed a commit
that referenced
this pull request
Oct 26, 2026
在 contributors/my12yyds/ 下新增 5 个 Excel 处理方法,并按仓库约定在 skills/excel/<方法>/ 下补齐 Skill 包装与 SKILL.md: - excel_diff: 比对两份 Excel,支持按主键配对,主键重复/为空直接报错 - excel_dedupe: 按列或整行去重,返回重复明细而非仅计数 - excel_column_stats: 逐列画像,输出填充率、类型、唯一值数与数值分布 - excel2json: 工作表转 JSON,支持 records / columns / values 三种结构 - excel2csv: 导出 CSV,默认 utf-8-sig 规避中文乱码,支持多表批量 skills/excel/__init__.py 仅在末尾追加 5 个导入与 __all__ 条目,未改动既有行。 未触碰 office/ 等核心目录,仅依赖 openpyxl,Python 3.6+ 兼容。 附 39 条单元测试(contributors/my12yyds/test_excel_toolkit.py)。 Co-authored-by: my12yyds <my12yyds@users.noreply.github.com>
Owner
|
已合入 合入 commit: 验证情况:
几个做得好的地方:
一个小建议(不影响本次合入): 期待你的后续贡献! |
CoderWanFeng
pushed a commit
that referenced
this pull request
Oct 26, 2026
发布 1.1.0:合入 #183 / #184 / #185 三个 PR,以及自 1.0.6 以来的全部修复。 主要内容: - feat(cli): 第一波 CLI 实现 —— `po` 命令 (#184) - feat(contributors): 5 个 Excel 数据核对与整理方法 (#185) - feat(contributor): batch_rename_by_excel (#183) - fix(excel): 拆分时保留 0 值 (#180) - fix(finance): t0 的 Decimal/float TypeError (#181) - fix(excel): 拆分输出工作簿有效性 (#182) - 及其他 1.0.6 以来的修复与文档更新 - 合并 main 独有的 #141 / #155 版本号: 1.0.6 → 1.1.0
CoderWanFeng
pushed a commit
that referenced
this pull request
Oct 26, 2026
## 问题
6 个贡献者 Skill 的 `__init__.py` 用 try/except 兜底处理「contributors 目录
不随包发布」的情况,但写法是:
except ImportError as _import_error:
def xxx(*args, **kwargs):
raise ImportError('...') from _import_error
Python 3 在 except 块结束后会自动 `del` 掉 `as` 绑定的异常名,闭包里引用
的 `_import_error` 因而是未定义名字。在真实的 pip 安装环境(contributors
目录不存在)下调用这些 Skill,实际抛出的是:
NameError: name '_import_error' is not defined
而不是作者预期的、带有明确指引的 ImportError 提示。
## 影响范围
- skills/file/batch_rename_by_excel(#183)
- skills/excel/excel_diff、excel_dedupe、excel_column_stats、
excel2json、excel2csv(#185)
## 修复
把异常对象存到模块级变量 `_CONTRIBUTORS_IMPORT_ERROR`,闭包引用该变量,
既修正了 NameError,也保留了原始 ImportError 作为 `__cause__` 异常链。
## 回归覆盖
新增 tests/test_code/test_contributors_skill_fallback.py,显式 mock 掉
contributors 导入来触发兜底分支。该分支在源码仓库内永远不会自然触发,
所以常规测试抓不到这个 bug——回退修复后新测试 12 个 subtest 全部失败。
Co-authored-by: my12yyds <my12yyds@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这个 PR 做了什么
在
contributors/my12yyds/下新增 5 个 Excel 数据核对与整理方法,补齐「表格处理」链条里目前缺的一环:现有方法主要解决格式转换与合并,这次补上比对、去重、质量统计。excel_diffmerge2excel是合并,本方法是找差异excel_dedupeexcel_column_statsfind_excel_data是按关键词找内容,本方法是按列做画像excel2jsonexcel2markdown输出给人看,本方法输出给程序读excel2csvutf-8-sig解决中文乱码,支持多表批量excel2pdf输出 PDF,本方法输出纯文本几个实现上的取舍:
excel_diff支持主键模式。只按行号比对,一旦有人插了一行,后面全部标红;指定key_column后先按主键配对再比字段,行顺序变化不会产生噪音。主键重复或为空会直接报错,避免静默给出错误结论。excel_dedupe返回重复明细而不是只返回行数。排查问题时需要知道「第 5 行和第 2 行重复」,只给一个数字没法用。excel2csv默认utf-8-sig。这是中文用户最常见的坑:存成 UTF-8 再用 Excel 双击打开会乱码,加 BOM 就正常;需要给 Linux 工具链消费时可以传encoding='utf-8'。是否遵守贡献约定
contributors/my12yyds/,未改动office/等核心目录skills/excel/<方法>/下补充 Skill 包装与SKILL.mdskills/excel/__init__.py有 1 处改动:追加 5 个导入与__all__条目,只在末尾新增,没有改动既有行。这与之前skills/file/__init__.py的做法一致。如果维护者希望贡献者的方法不进入统一导出,我可以撤掉这处改动,只保留skills/excel/<方法>/目录。测试
连同既有的
test_batch_rename_by_excel.py一起跑:47 个用例全部通过。测试覆盖了正常路径、空单元格、重复列名、日期类型、中文编码 BOM、路径不存在、参数非法等边界情况。关于
DECLARATION.md新增了一份声明文件,内容包括作者、贡献清单、许可(Apache-2.0,与项目一致)、边界声明(只处理本地文件、不联网、不修改原文件)和维护承诺。
需要说明一点:文件里写的「核心维护者」仅指本贡献模块的维护责任人,即
contributors/my12yyds/下的代码由我负责修复和兼容。它不表示、也不应被理解为对 python-office 上游项目的维护权或发布权——上游的维护与发布当然仍由 @CoderWanFeng 决定。如果这个措辞让维护者觉得不妥,我可以改掉或直接删除该文件。兼容性
openpyxl(已在项目依赖链中),没有引入新的第三方包setup.cfg的python_requires一致