Quickstart

On this page

This page gets you from zero to loaded documents in under five minutes.

1. Load a single file — the easy way

AutoLoader is the recommended entry point. It detects whether your input is a file, a URL, or a directory, picks the right loader by extension, and returns LoadedDocument objects.

Python · 6 lines
from zerda.document_loaders import AutoLoader

docs = AutoLoader.load("report.pdf")
print(f"Loaded {len(docs)} document(s)")
print(docs[0].page_content[:300])
print(docs[0].metadata)

AutoLoader.load() works the same way for any supported input:

Python · 8 lines
AutoLoader.load("notes.txt")
AutoLoader.load("article.md")
AutoLoader.load("data.csv")
AutoLoader.load("workbook.xlsx")
AutoLoader.load("records.json")
AutoLoader.load("page.html")
AutoLoader.load("https://example.com/article")   # → WebLoader
AutoLoader.load("./my_documents/")                # → DirectoryLoader

2. Pass loader-specific options through **kwargs

AutoLoader.load(source, **kwargs) forwards extra keyword arguments to whichever loader it selects:

Python · 5 lines
# Password-protected, page-range-limited PDF
docs = AutoLoader.load(
    "confidential.pdf",
    password="secret123",
)

3. Use a specific loader directly

When you need full control, import the concrete loader class. Every loader follows the same load() -> List[LoadedDocument] contract.

Python · 5 lines
from zerda.document_loaders import PDFLoader, PDFLoaderConfig

config = PDFLoaderConfig(start_page=4, end_page=10, per_page=True)
loader = PDFLoader("book.pdf", config=config)
pages = loader.load()

4. Inspect a LoadedDocument

Python · 5 lines
doc = docs[0]
doc.page_content   # str — the extracted text
doc.metadata        # dict — source path, loader type, timestamps, format-specific fields
doc.doc_id           # str — a deterministic SHA-256-derived ID (stable across runs)
len(doc)             # character count of page_content

See LoadedDocument for the full data model.

5. Load an entire directory

Python · 8 lines
from zerda.document_loaders import DirectoryLoader

loader = DirectoryLoader("./knowledge_base/", recursive=True, silent_errors=True)
docs = loader.load()

stats = loader.get_stats()
print(stats)
# {'total_files': 42, 'by_type': {...}, 'total_size_bytes': ..., 'total_size_mb': ...}

DirectoryLoader loads files concurrently by default (use_multithreading=True, 4 workers) and silently skips any file extension it doesn't recognize.

6. Split documents while loading

Every loader inherits load_and_split() from BaseDocumentLoader, which lets you pass any object exposing a split_text(text) -> List[str] method (e.g. a text splitter from your chunking library):

Python
chunks = loader.load_and_split(text_splitter=my_splitter)

Each resulting chunk is a new LoadedDocument whose metadata includes chunk_index, total_chunks, and original_doc_id linking it back to its parent document.

Next steps

Related pages