Extracting Tables only

Luzuko Yena 20 Reputation points
2025-04-16T17:34:40.0833333+00:00

Is there a way of extracting tables only using Azure AI Document Intelligence

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
2,016 questions
0 comments No comments
{count} votes

Accepted answer
  1. Prashanth Veeragoni 3,465 Reputation points Microsoft External Staff
    2025-04-16T18:04:42.43+00:00

    Hi Luzuko Yena,

    Yes, it is possible to extract only tables using Azure AI Document Intelligence.

    Azure AI Document Intelligence provides multiple models to analyze documents, such as:

    ·       Prebuilt Layout Model

    ·       Prebuilt Document Model

    ·       Custom Models

    To extract only tables, you should use the Layout Model, which is designed for this purpose.

    What it does:

    ·       Extracts text lines

    ·       Extracts tables (structure + cell content)

    ·       Extracts selection marks (checkboxes)

     It does not extract key-value pairs or entities — perfect if you're only focused on layout elements like tables.

    To Use (via REST API / SDKs / Azure Portal)

    Example using Python SDK:

    from azure.ai.formrecognizer import DocumentAnalysisClient
    from azure.core.credentials import AzureKeyCredential
    
    endpoint = "https://<your-resource-name>.cognitiveservices.azure.com/"
    key = "<your-key>"
    
    document_analysis_client = DocumentAnalysisClient(
        endpoint=endpoint, credential=AzureKeyCredential(key)
    )
    
    # Use layout model
    poller = document_analysis_client.begin_analyze_document(
        "prebuilt-layout", document=open("your_file.pdf", "rb")
    )
    result = poller.result()
    
    # Extract tables only
    for table in result.tables:
        print(f"\nTable with {table.row_count} rows and {table.column_count} columns")
        for cell in table.cells:
            print(f"Cell [{cell.row_index}, {cell.column_index}] - content: '{cell.content}'")
    

    Hope this helps. Do let me know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    Thank you!  

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Gowtham CP 5,945 Reputation points
    2025-04-16T18:05:09.3266667+00:00

    Hey Luzuko Yena,

    Thanks for asking on Microsoft Q&A!

    You can pull tables using Azure AI Document Intelligence with the prebuilt-layout model. It grabs tables, text, and other stuff, but there’s no direct way to get only tables from the API. Just take the JSON response and pick out the "tables" section in your code. For example, in Python, you’d grab the rows, columns, and cell data from "tables", skipping everything else.

    Hope this does the trick! If it helps, please upvote and mark as accepted. Thanks!

    References:

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.