Registry / aws / textract-trp

textract-trp

JSON →
library0.1.3pypypi✓ verified 81d ago

A parser for Amazon Textract results that converts the raw JSON response into a structured document model with pages, lines, words, tables, and forms. Version 0.1.3 (latest as of verification) supports Python >=3.6. The library provides high-level abstractions for navigating Textract output, including bounding boxes, confidence scores, and relationships between elements. It is maintained on GitHub by mludvig.

pip install textract-trp
INSTALL
IMPORT
SIG · TEXTRACT-TRP
T
textract-trp
awspythonv0.1.3
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Document
from trp import Document
from textract_trp import TextractParser
Page
from trp import Page
Table
from trp import Table

Parse Amazon Textract output into a structured document with pages, lines, tables, and forms.

import boto3 from textract_trp import TextractParser # Initialize Textract client client = boto3.client('textract', region_name='us-east-1', aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', ''), aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', '')) # Analyze a document from S3 response = client.analyze_document( Document={'S3Object': {'Bucket': 'my-bucket', 'Name': 'document.pdf'}}, FeatureTypes=['TABLES', 'FORMS'] ) # Parse the response parser = TextractParser() document = parser.parse(response) # Iterate pages and lines for page in document.pages: for line in page.lines: print(line.text) # Access tables for page in document.pages: for table in page.tables: for row in table.rows: print([cell.text for cell in row.cells])
Debug
Known issues
gotchaThe library does not handle pagination of Textract responses with multiple pages. You must call Textract with the 'NextToken' yourself and parse each response separately.
fix
Loop over responses by passing NextToken from previous response until NextToken is missing.
affects: all
deprecatedVersion 0.1.3 uses 'pip install textract-trp' but the package name on PyPI is 'textract-trp'. Some older documentation references 'textract' which is a different library (for OCR).
fix
Always use 'pip install textract-trp'. Do not confuse with 'textract' (general OCR) or 'amazon-textract-textractor'.
affects: >=0.1.0
gotchaTextractParser.parse() expects the raw response dictionary from boto3, not the JSON string. Passing a string will cause JSONDecodeError or attribute errors.
fix
Ensure you pass the response object directly from the boto3 client call, e.g., result = client.analyze_document(...); document = parser.parse(result).
affects: all
breakingIn version 0.1.3, the TRP class attributes have changed from previous releases. 'page.lines' and 'page.words' are now objects, not lists of strings. Accessing .text on these objects is correct.
fix
Use .text property on line and word objects. For plain list of strings, use list comprehension: [line.text for line in page.lines].
affects: >=0.1.0
Upgrade
Version history
0.1.3latest on PyPI · released May 4, 2020
Audit
Dependencies
boto3requiredFor calling Amazon Textract API and handling responses.
Agent activity
33 hits · last 30 days
node
26
OpenAI (training)
1
Resources
textract-trp — pip install textract-trp · libregistry