DOCX

gllm-docprocarrow-up-right | Tutorial: DOCX Loader | Use Case: Advanced DPO Pipeline | API Referencearrow-up-right

DOCX Loader is a component designed for extracting information from a DOCX file and converting it into a standardized JSON format.

chevron-rightPrerequisiteshashtag

This example specifically requires completion of all setup steps listed on the Prerequisites page.

Installation

# you can use a Conda environment
pip install --extra-index-url https://oauth2accesstoken:$(gcloud auth print-access-token)@glsdk.gdplabs.id/gen-ai-internal/simple/ "gllm-docproc[docx]"

You can use the following as a sample file: docx-example.docxarrow-up-right.

Python DOCX Loader

PythonDOCXLoader is responsible to extract Text and Tables from within DOCX document body by using the docx2python library.

1

Create a script called main.py:

from gllm_docproc.loader.docx import PythonDOCXLoader

source = "./data/source/docx-example.docx"

# initialize Python DOCX Loader
loader = PythonDOCXLoader()

# load source
loaded_elements = loader.load(source)
2

Run the script:

python main.py
3

The loader will generate the following: output JSONarrow-up-right.

DOCX2Python Loader

DOCX2PythonLoader is responsible to extract Text, Tables, and Images from within DOCX document by using the python-docx library.

1

Create a script called main.py:

2

Run the script:

3

The loader will generate the following: output JSONarrow-up-right.

Python DOCX Table Loader

PythonDOCXTableLoader is responsible to extract Tables from within DOCX document body by using the python-docx library.

1

Create a script called main.py:

2

Run the script:

3

The loader will generate the following: output JSONarrow-up-right.

Last updated