What you are going to build
Docling reads a PDF, a Word file, a spreadsheet or a web page and gives you back one Python object with the same shape every time. This course builds a searchable handbook for an online shop out of four files in four different formats, and every lesson runs on your machine.
A document is easy for a person to read and awkward for a program. A PDF is drawing instructions. A spreadsheet is cells. An HTML page is tags. Getting the words out of each one is a different job with a different library, and none of them tells you that a line was a heading.
Docling does that job once, for every format, and hands back the same object. This lesson runs the finished thing so you can see where the course goes.
The shop handbook, answering a question
from handbook import build, ask
index, report = build()
print(ask(index, "how long does a refund take?"))The answer came out of a table inside an HTML file. The line under it says which file, which heading it sat under, and, when the file was a PDF, which page. That is the whole point of the course: an answer you can check.
from handbook import build, ask
index, report = build()
print(ask(index, "can I return a damaged item?"))Same call, different file. This one came from a two page PDF, and the citation says which page of it. handbook.py is yours by lesson 29; nothing in it is longer than the pieces you build one at a time along the way.
Four files, four formats
The shop keeps its support handbook in whatever format each person happened to use. That is normal, and it is why a tool like this exists.
| File | Format | What is in it |
|---|---|---|
shipping.md | Markdown | Delivery times and tracking, under two headings |
refunds.html | HTML | A paragraph and a table of refund times |
orders.csv | CSV | Three orders and their status |
returns.pdf | A two page returns policy |
All four are on this page, in the lessons that first use them, and you can build the PDF yourself with a script shown in lesson 13. No file here is bigger than a screen.
What you will have built
| Piece | What it does | Lesson |
|---|---|---|
convert | One call that reads any of the four files | 2 |
| The document object | Text, tables and their order, in one shape | 5 to 9 |
| Exports | Markdown, plain text, HTML and DocTags back out | 10 to 12 |
| The PDF pipeline | Pages, boxes, heading levels and a quality grade | 13 to 17 |
| Batch conversion | Four files at once, and the ones that failed | 18 to 21 |
| Chunking | Cutting a document into pieces worth searching | 22 to 25 |
| The handbook | An index, a report and an answer with a citation | 28 and 29 |
What you need
- Python 3.10 or newer.
pip install docling. That is the only install in the whole course.- No account, no API key, no card. Docling runs its models on your machine.
- About half a gigabyte of disk for the PDF models, downloaded the first time you convert a PDF in lesson 13. Lessons 1 to 12 need none of it.
- Read the table above and pick the row you want most. That is the lesson to look forward to.
- Find a document on your own machine that a program has never been able to read. That is what this course is for.
Every expert started right here.