liveBook · Manning

Document loader

As explained in Build Python Web Apps with Streamlit

A document loader is a component that reads source data and converts it into structured documents for downstream processing.

A document loader reads source data and converts it into structured Document objects for downstream processing. In a retrieval-augmented generation workflow, it turns files into material that can be split, embedded, and stored for search. section 10.5.2

Loading text files from a folder

DirectoryLoader scans a folder, while TextLoader handles each matching text file. With glob="**/*.txt", loader.load() returns a list of Document objects, including the files' raw text and metadata. A text splitter can then divide long articles into smaller chunks before vector-store ingestion.

A practical ingestion sequence is:

  • Choose a loader suited to the source, such as TextLoader for individual text files. section 10.5.2

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains loader selection and folder loading, but does not detail parsing internals for formats beyond text files.
Examples
Uses DirectoryLoader, TextLoader, a recursive text splitter, and an articles folder containing text files.
What you can do after
Build it from scratch by loading a folder of text files and preparing Document objects for vector-store ingestion.
How it connects
Connects document loading with text splitting, metadata, embeddings, vector stores, and retrieval-augmented generation.

Also explained in

Compare how 3 books explain document loader →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.