How kareenabeniwal-atlascopco/extract-content-from-excel-document-intelligence works
Project Type and Purpose
• This is a simple, single‐service batch processing tool written in Python.
• It reads Excel files from a local directory, sends them to Azure Document Intelligence (ADI) for extraction, and writes the results as JSON into another local directory.
• There is no traditional frontend or database; the only external dependency is the Azure Document Intelligence API.
Main Components to Illustrate
a. File System – Input
• “input_documents” folder containing .xlsx files
b. Environment Configuration
• .env file holding ADI_ENDPOINT and ADI_API_KEY
c. Processing Engine
• 1_excel_to_json.py Python script
• Key libraries: dotenv (env loader), requests (HTTP calls), json (serialization)
d. External Service
• Azure Document Intelligence “prebuilt-layout” model endpoint
e. File System – Output
• “content_json” folder where extracted JSON is saved
Relationships and Data Flow
1. The user invokes python 1_excel_to_json.py
2. The script loads environment variables from .env
3. The script enumerates all .xlsx files in input_documents/
4. For each file:
– The script reads binary data
– Sends an HTTP POST to the ADI endpoint with the file payload and API key
– Receives a 202 Accepted response with an Operation-Location URL
– Polls that URL (with GET) until the status is “succeeded”
– Receives the full extraction result as JSON
– Writes the JSON result to content_json/<filename>.json
5. Script exits once all files are processed
Architectural Patterns & Design Principles
• Batch Pipeline Pattern: file ingestion → external processing → file export
• Single Responsibility: the Python script handles orchestration, API communication, and I/O
• Configuration Isolation: secrets and endpoints stored outside code in .env
• Polling Loop: simple retry/polling mechanism rather than event-driven callbacks
Technologies & Frameworks
• Python 3.6+ runtime
• dotenv for env var management
• requests for HTTP interactions
• Azure Document Intelligence REST API
Final Advice
• Be explicit about every directory and HTTP interaction.
• Error/polling loop as a small sub‐flow detail around the ADI API call.