AI / LlamaIndex Interview Questions
How do you use SimpleDirectoryReader?
SimpleDirectoryReader is LlamaIndex's default loader for pulling local files into Documents. Point it at a folder and it will read the files inside, inferring the right parser for common formats like .txt, .pdf, .docx, .csv, and .md automatically.
from llama_index.core import SimpleDirectoryReader documents = SimpleDirectoryReader("./data").load_data()
Each file becomes one or more Document objects, with metadata such as file_name and file_path attached automatically. You can filter which files get loaded with required_exts, recurse into subfolders with recursive=True, or exclude specific files with exclude.
Once you have the documents, they're typically passed straight into an index constructor, for example VectorStoreIndex.from_documents(documents).
More Related questions...