Sitemap
Angelo

Angelo

Automation System for AI Data Extraction & Form Filling

3 min readDec 4, 2025

If you’ve ever tried manually extracting data from real-estate appraisal documents, you know the struggle: PDFs and Word files coming in all shapes and formats, long descriptions that seem impossible to normalize, and hours wasted filling forms with information that could—and should—be automated. For brokers, property managers, and analysts, this bottleneck is more than annoying; it slows operations, introduces errors, and makes scaling nearly impossible.
In this post, I’ll walk you through building an end-to-end automation system that tackles this exact problem using Python, AI models, and browser automation. We’re going to parse documents, normalize data intelligently, and automatically fill forms—all in a reproducible, scalable way.

Understanding the Pain Point
The problem is twofold:


Document Chaos: Real-estate documents contain a mix of structured tables, free-text descriptions, and sometimes even handwritten notes. Standard parsing rarely works across all formats.


Manual Form Filling: Once you extract the data, populating web forms or internal systems is tedious and error-prone. A single mistake in cadastral numbers, property type, or expense fields can cascade into bigger issues.


Manual work slows the process down, and conventional automation scripts often break when document formats change.

The Solution Architecture
To solve this, we need three layers:


Document Input & Parsing


Accept PDFs and Word documents.


Use direct parsing for structured tables.


Apply OCR for scanned or image-based files.


Leverage AI/LLMs (OpenAI models) to understand complex free text and map it to JSON fields.




Data Processing & Normalization


Introduce a normalization layer to standardize values.


Use AI to clean text, resolve ambiguous entries, and map lengthy descriptions into predefined form fields.




Browser Automation


Use Selenium or Playwright to automate form filling.


Map the normalized JSON fields directly into your web application forms.


Include error handling and logging to track any mismatches or failed submissions.





Step 1: Document Parsing
We start by ingesting files. PDFs can be read with PyPDF2 or pdfplumber, Word documents with python-docx. For scanned images, pytesseract handles OCR.
pythonCopy codefrom pdfplumber import open as open_pdf
import pytesseract
from PIL import Image

def extract_text(file_path):
if file_path.endswith('.pdf'):
with open_pdf(file_path) as pdf:
return "\n".join(page.extract_text() for page in pdf.pages)
elif file_path.endswith('.docx'):
import docx
return "\n".join([p.text for p in docx.Document(file_path).paragraphs])
else:
return pytesseract.image_to_string(Image.open(file_path))

At this point, you have raw text ready for AI interpretation.

Step 2: AI-Powered Normalization
The next step is cleaning and structuring the data. Here’s where OpenAI or similar LLMs shine. They can map messy descriptions into structured fields like property type, location, or expense categories.
pythonCopy codefrom openai import OpenAI

client = OpenAI(api_key="YOUR_API_KEY")

def normalize_data(raw_text):
prompt = f"Extract property details from the following text and return as JSON with fields: property_type, destination, cadastral_data, expenses, description:\n\n{raw_text}"
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": prompt}]
)
return response.choices[0].message['content']

The output is a clean JSON ready to feed into our form automation.

Step 3: Browser Automation with Selenium
Finally, we bridge the gap between structured data and the target form.
pythonCopy codefrom selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://example-form.com")

def fill_form(data):
driver.find_element_by_name("property_type").send_keys(data['property_type'])
driver.find_element_by_name("destination").send_keys(data['destination'])
driver.find_element_by_name("cadastral_data").send_keys(data['cadastral_data'])
driver.find_element_by_name("expenses").send_keys(data['expenses'])
driver.find_element_by_name("description").send_keys(data['description'])
driver.find_element_by_id("submit").click()

This step automates repetitive data entry flawlessly, reducing errors and freeing up hours of manual labor.

Deployment & Reflections
Deploying this system can be as simple as running it on a local server or integrating it into a Django/Flask backend for real-time processing. A scheduled cron job could monitor incoming documents and process them automatically.
Lessons Learned:


Data inconsistency is the real challenge. AI normalization solves much of it but always include manual verification for edge cases.


OCR quality can vary; preprocessing images to improve contrast often yields better extraction.


Error handling is crucial in browser automation—forms change frequently, so logging failures is non-negotiable.



FAQs
Q: Can this handle multiple document types at once?
Yes. The parser can branch based on file type and use the appropriate extraction method.
Q: Is AI strictly necessary?
For complex textual descriptions and ambiguous values, yes. Traditional regex or rule-based parsing often fails.
Q: Can this be extended to other industries?
Absolutely. Any scenario where structured forms are filled from unstructured or semi-structured documents can benefit—from finance to healthcare.

By combining Python, AI models, OCR, and browser automation, we’ve built a system that turns manual document chaos into a structured, automated workflow. This approach saves time, reduces errors, and can scale as document volumes grow—transforming a tedious, error-prone process into a smooth, intelligent operation.
Copy code

--

--