通用文档读取工具,支持 PDF/DOCX/XLSX/PPTX/RTF/ODT 等多种文档格式,也支持ZIP/TAR.GZ/RAR/7Z 等主流压缩包内文档直接读取
读取各种格式文档的内容,直接输出文本供 AI 分析。支持压缩包内文档直接读取,无需手动解压。
格式扩展名说明PDF.pdf支持文本提取,依赖 poppler-utilsMicrosoft Word.docx完整提取所有段落文本Microsoft Excel.xlsx按 Sheet 输出,每个 Sheet 输出为表格文本Microsoft PowerPoint.pptx按 Slide 分块输出Rich Text Format.rtfOpenDocument Text.odtHTML.html/ .htm提取正文文本纯文本.txt/ .md/ .json/ .xml/ .py/ .js 等直接读取
格式扩展名功能ZIP.zip列出文件 ➜ 读取指定文档TAR.tar/ .tar.gz/ .tgz/ .tar.bz2列出文件 ➜ 读取指定文档RAR.rar列出文件 ➜ 读取指定文档7-Zip.7z列出文件 ➜ 读取指定文档
Python 包:
bash
pip install textract python-docx openpyxl python-pptx rarfile py7zr --break-system-packages
系统依赖(Ubuntu/Debian):
bash
apt-get install -y poppler-utils antiword unrtf tidy libxml2-dev libxslt1-dev
bash
# 读取 PDF 文件
python {baseDir}/scripts/document_reader.py --file /path/to/document.pdf
# 读取 Word 文档
python {baseDir}/scripts/document_reader.py --file /path/to/report.docx
# 读取 Excel 文件(输出带 Sheet 分隔的表格文本)
python {baseDir}/scripts/document_reader.py --file /path/to/data.xlsx
# JSON 格式输出(方便程序处理)
python {baseDir}/scripts/document_reader.py --file /path/to/data.xlsx --format json
先列出压缩包里有哪些文件:
bash
# 列出 ZIP 包内容
python {baseDir}/scripts/document_reader.py --list /path/to/archive.zip
# 列出 RAR 包内容
python {baseDir}/scripts/document_reader.py --list /path/to/archive.rar
# 列出 7z 包内容
python {baseDir}/scripts/document_reader.py --list /path/to/archive.7z
读取压缩包里的指定文档:
bash
# 读取 ZIP 包内的 Word 文档
python {baseDir}/scripts/document_reader.py --file /path/to/archive.zip --inner-path document.docx
# 读取 7z 包内的 PDF
python {baseDir}/scripts/document_reader.py --file /path/to/archive.7z --inner-path report.pdf
读取文档:
text
=== report.pdf ===
# 项目进度报告
## 本周完成
1. 完成了前端界面开发
2. 修复了三个 Bug
3. 编写了接口文档
...
列出压缩包:
text
Archive: data.zip
Found 3 file(s):
readme.txt
docs/report.pdf
data/sheet.xlsx
Created by xiaoya Liu with OpenClaw