在Python中使用Amazon Textract从多个图像中提取多表

问题描述

我是Python的初学者。我正在开发有关发票分类的项目。我正在使用Amazon Textract从Python图像中提取信息。

为了遍历大量文件(以3张图像为例),我创建了这些代码

    import boto3
    from trp import Document
    
    #Document
    s3BucketName = "Your Bucket Name"
    Name = ['Image1.jpg','Image2.jpg','Image3.jpg']

for i in Name:
    documentName = i
    #Amazon Textract client
    textract = boto3.client('textract')
    
    #Call Amazon Textract
    response = textract.analyze_document(
        Document={
            'S3Object': {
                'Bucket': s3BucketName,'Name': documentName
            }
        },FeatureTypes=["TABLES"])
    
    #print(response)
    doc = Document(response)
    print(doc)



####Table Extraction###
for page in doc.pages:
     # Print tables
    for table in page.tables:
        for r,row in enumerate(table.rows):
            for c,cell in enumerate(row.cells):
                print("Table[{}][{}] = {}".format(r,c,cell.text))

但是,我无法使用此循环提取每个表。您能帮我解决这个问题吗?谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)