如果十段 Gemini 会话都含表格,导出后只有九份文档能读到表格结构,就值得优先打开剩下那份检查。结构清点能帮你缩小人工检查范围,最终仍要对照原会话内容。
先在 Gemini 网页通过鲸鱼AI助手浏览器插件选择目标历史会话,批量导出 Word。将本批文件单独放到一个目录,记录每个目标会话的标题和首问关键词。
用 Python 读取 DOCX
DOCX 使用 ZIP 容器,正文通常在 word/document.xml 中。下面命令运行随文提供的 inspect_docx_batch.py,会在终端打印 JSON 清单。 Microsoft 文档结构说明
Powershell
python inspect_docx_batch.py "D:\Gemini归档\本批Word"
清单保留相对于归档目录的路径,并统计段落、表格、原生公式和超链接节点。文件打不开、正文 XML 缺失或损坏时,记录错误后继续读取下一份。脚本使用 Python 标准库,可随文章作为代码附件发布。
| 字段 | 用来观察什么 |
|---|---|
| status | ZIP 和正文 XML 是否可读取 |
| tables | 正文内是否存在 Word 表格节点 |
| equations | 正文内是否存在原生公式节点 |
| hyperlinks | 正文内是否存在超链接节点 |
把计数和原会话对应
例如「预算复核」原回答含一张表,清单却显示 tables: 0,先打开该 Word,检查是否保存成图片或纯文本。「函数练习」的 equations: 0 同样需要打开文件检查表达式。反过来,计数大于零也要抽查一个单元格或公式,确认内容和编辑结果。
脚本统计主正文 XML 节点,超链接字段、文本网址和图片式公式可能以其他形式保存。节点计数适合发现需要复核的文件,文档是否完整、公式计算是否正确仍应对照源会话。它也不会列出没有生成的会话,因此开始时的选择清单要保留。
把「目标会话 → 文件路径 → 清点结果 → 人工核对」记在一起,之后补导或交接都能找到具体文件。 Gemini 历史会话导出指南
完整脚本
保存为 inspect_docx_batch.py 后运行上面的命令。
Python
"""Inventory DOCX structures without changing exported files."""
import argparse
import json
from pathlib import Path
from zipfile import ZipFile, BadZipFile
import xml.etree.ElementTree as ET
NS = {"w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
"m": "http://schemas.openxmlformats.org/officeDocument/2006/math"}
def inspect(path, root):
row = {"file": path.relative_to(root).as_posix()}
try:
with ZipFile(path) as archive:
bad = archive.testzip()
if bad:
raise ValueError(f"ZIP CRC failed: {bad}")
document = ET.fromstring(archive.read("word/document.xml"))
row.update(status="readable", paragraphs=len(document.findall(".//w:p", NS)),
tables=len(document.findall(".//w:tbl", NS)),
equations=len(document.findall(".//m:oMath", NS)),
hyperlinks=len(document.findall(".//w:hyperlink", NS)))
except (BadZipFile, KeyError, ET.ParseError, OSError, ValueError) as error:
row.update(status="error", error=str(error))
return row
def main():
parser = argparse.ArgumentParser()
parser.add_argument("folder", type=Path)
args = parser.parse_args()
root = args.folder.resolve()
if not root.is_dir():
parser.error("folder must be an existing directory")
rows = [inspect(path, root) for path in sorted(root.rglob("*.docx")) if not path.name.startswith("~$")]
print(json.dumps(rows, ensure_ascii=False, indent=2))
if __name__ == "__main__":
main()
1920




被折叠的 条评论
为什么被折叠?



