Doclingdocling 2.127.0 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
26 small wins to finish your pathNext lesson

The files Docling will not read

Lesson 18's bad file was refused for the right reason. Refusing files on purpose is a separate and useful thing.

Example
from docling.document_converter import DocumentConverter
from docling.exceptions import ConversionError

try:
    DocumentConverter().convert("notes.xyz")
except ConversionError as refused:
    print(refused)

File format not allowed, and the status inside is skipped rather than failure. Docling draws that line carefully: skipped means it would not try, failure means it tried and could not.

Refusing on purpose

A converter can be built to accept only some formats. Anything else is skipped with the same message, even though Docling knows perfectly well how to read it.

Example
from docling.datamodel.base_models import InputFormat

only_text = DocumentConverter(allowed_formats=[InputFormat.MD, InputFormat.HTML])
print(only_text.convert("shipping.md").status.name)
try:
    only_text.convert("returns.pdf")
except ConversionError as refused:
    print(refused)

Two good reasons to do this. A service that should never spend two minutes on a PDF can refuse them at the door, and a pipeline that expects Word files can fail loudly when someone drops in a spreadsheet instead of silently converting it.

The thirty-three

Example
from docling.datamodel.base_models import InputFormat

names = sorted(fmt.value for fmt in InputFormat)
print(len(names))
print(names[:10])
print(names[-8:])

Office documents, images, audio, video, email, EPUB and several XML schemas. The ones this course uses are four of them. A format being on the list does not mean it needs no extra install: audio and video need the speech recognition extra, and the older Office formats need LibreOffice on the machine.

The extension is the guess

Docling decides the format from the file name first and sniffs the contents second. That is why orders.txt and orders.csv holding identical bytes are read differently, and why the stream in lesson 20 has to be given a name.

Skipped is not an error you can ignore. In a batch with raises_on_error=False a skipped file produces a result whose document is empty. Indexing it adds nothing and hides the problem.
Try it yourself
  • Build a converter allowing only InputFormat.PDF and run it over all four files.
  • Rename refunds.html to refunds.txt and see which backend reads it.
  • Print result.status for a .md file that does not exist, and compare it with the skipped one.

This is what real progress feels like.