'Extract table data and put them into dictionary with azure form recognizer
I have searched related to my question but none found.
Below is my tried working code:
import json
from azure.core.exceptions import ResourceNotFoundError
from azure.ai.formrecognizer import FormRecognizerClient, FormTrainingClient
from azure.core.credentials import AzureKeyCredential
credentials = json.load(open("creds.json"))
API_KEY = credentials["API_KEY"]
ENDPOINT = credentials["ENDPOINT"]
url = "https://some_pdf_url_which_contains_tables.pdf" #or image url which contains
#table
form_recognizer_client = FormRecognizerClient(ENDPOINT, AzureKeyCredential(API_KEY))
poller = form_recognizer_client.begin_recognize_content_from_url(url)
form_data = poller.result()
for page in form_data:
for table in page.tables:
for cell in table.cells:
for item in cell.text:
print(item)
## But I need table in dictionary format with header names in keys and
## values in values.
I hope I get some help. Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
