Generative AI · Intermediate level

Intermediate level · Module 7: Document Processing and Chunking · Lesson 1 of 3

Loading and Cleaning Documents

Learners extract text from PDFs, Word documents and web pages, remove headers, footers and noise, and keep structure such as headings and tables.

In this lesson you will

  • Extract text from common formats
  • Clean text while preserving structure

Key concepts

text extractionscanned vs digital PDFsheaders and footerstablesstructure preservation

The lesson

Digital PDFs and Word files contain text that can be extracted; scanned PDFs are images and need OCR first, which is slower and less accurate. Web pages need boilerplate removed.

Clean repeated headers, footers and page numbers, fix broken lines, and keep headings and tables, because they help retrieval and citations.

Record each document's title, date, source and access level as metadata during loading.

Step by step

  1. Load three formats from the project collection.
  2. Compare extracted text with the originals.
  3. Clean headers, footers and broken lines.
  4. Record metadata for each document.

Practice activity

Write a loader and cleaner for the project collection with metadata.

Expected result: Clean, structured text and metadata for every document.

Check your understanding

  1. What extra step do scanned PDFs need?

    Show answer

    OCR (optical character recognition).

  2. Why keep headings during cleaning?

    Show answer

    They help retrieval and make citations clearer.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.