trading_agent.attachments.word_text_reader
¶
Reads the text of a Word document (.docx) with python-docx: its paragraphs, then its tables.
The older .doc format is a different, binary format that python-docx cannot open, so it is not accepted.
Typical usage example:
extracted = WordTextReader().read(Path('plan.docx'))
WordTextReader
¶
Bases: TextReader
Reads a .docx file.
read
¶
Reads the paragraphs, and each table row with its cells separated by " | ".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The document. |
required |
Returns:
| Type | Description |
|---|---|
ExtractedText
|
Its text. |
Raises:
| Type | Description |
|---|---|
TextReadError
|
The file is damaged or is not a .docx file. |