本文へスキップ
Skillpedia
PDF・Word・スライド7.8k · #12866

docx-read-fallback

できること

このスキルは、より単純な方法が失敗したときに、python-docxライブラリを使って.docxファイルから文章、表、見出しを取り出す方法をAIに示します。それ以外では開けないWord文書を読む必要がある人向けです。

使う場面

  • ✓.docxファイルで、ファイルリーダーが失敗するかタイムアウトするとき。
  • ✓Word文書の文章、表、見出しが必要なとき。
  • ✓コード実行環境がWordファイルを読めないとき。

スキルのリンク

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/docx-read-fallback/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/docx-read-fallback/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“AIが私のWordファイルを開けません。そこから文章と表を取り出してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

AIは、シェルで短いPythonコマンドを実行します。そのコマンドはpython-docxを使って、ファイルの段落、表、見出しを表示します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

DOCX Read Fallback

When read_file or execute_code_sandbox fails to read .docx files, use run_shell with python-docx as a reliable workaround.

When to Use

  • read_file fails, times out, or returns errors on .docx files
  • execute_code_sandbox attempts to read the docx fail
  • You need to extract text content from a Word document
  • Multiple standard approaches have been exhausted

How to Use

Basic Text Extraction

python -c "import docx; doc = docx.Document('path/to/file.docx'); print('\n'.join([p.text for p in doc.paragraphs]))"

Using run_shell Tool

run_shell command="python -c \"import docx; doc = docx.Document('path/to/file.docx'); print('\n'.join([p.text for p in doc.paragraphs]))\"" timeout=60

Extract Paragraphs with Indices

python -c "import docx; doc = docx.Document('file.docx'); [print(f'P{i}: {p.text}') for i, p in enumerate(doc.paragraphs) if p.text.strip()]"

Extract Tables

python -c "import docx; doc = docx.Document('file.docx'); [[print([[cell.text for cell in row.cells] for row in table.rows]) for table in doc.tables]]"

Extract Headings (by style)

python -c "import docx; doc = docx.Document('file.docx'); [print(p.text) for p in doc.paragraphs if p.style.name.startswith('Heading')]"

Prerequisites

Ensure python-docx is available:

python -c "import docx; print('docx available')"

If not installed:

pip install python-docx

Tips

  • Use absolute paths to avoid working directory issues
  • Set appropriate timeout (30-60 seconds for large documents)
  • Escape quotes properly when embedding in shell commands
  • For large documents, extract content in chunks or filter by paragraph index
  • This approach bypasses file type detection issues in read_file

Example Workflow

  1. Try read_file on the .docx file
  2. If it fails, verify python-docx availability
  3. Use run_shell with the python-docx extraction command
  4. Parse the stdout to get document content
  5. Proceed with your analysis using the extracted text
よくある質問

python-docxとは何ですか?

Wordファイルを読み書きするPythonライブラリです。

表も読めますか?

はい。ガイドには、表の内容を表示するコマンドが含まれています。

何をインストールする必要がありますか?

コマンドを実行する前に、python-docxが使える必要があるとガイドは述べています。

詳細

作者による元の説明

Use run_shell with python-docx as reliable fallback when read_file fails on .docx files

repo: HKUDS/AgentPilot

人気

GitHubのスター
7.8k
ランキング
#12866
ライセンス
MIT
更新日
2026/11/1

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル