Challenge - 5 Problems
Directory Loader Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What does this DirectoryLoader code output?
Given this code snippet using Langchain's DirectoryLoader, what will be the output type of
documents?LangChain
from langchain.document_loaders import DirectoryLoader loader = DirectoryLoader('data/docs', glob='*.txt') documents = loader.load()
Attempts:
2 left
💡 Hint
Think about what the DirectoryLoader.load() method returns in Langchain.
✗ Incorrect
DirectoryLoader.load() returns a list of Document objects, each representing one loaded file.
📝 Syntax
intermediate1:30remaining
Which option correctly filters files with DirectoryLoader?
You want to load only PDF files from a folder using DirectoryLoader. Which code snippet is correct?
Attempts:
2 left
💡 Hint
Check the parameter name used for file matching in DirectoryLoader.
✗ Incorrect
The DirectoryLoader uses the 'glob' parameter to filter files by pattern.
🔧 Debug
advanced2:00remaining
Why does this DirectoryLoader code raise an error?
This code raises a FileNotFoundError. What is the most likely cause?
LangChain
from langchain.document_loaders import DirectoryLoader loader = DirectoryLoader('docs', glob='*.md') docs = loader.load()
Attempts:
2 left
💡 Hint
Check if the folder path is correct and exists.
✗ Incorrect
FileNotFoundError means the folder path is wrong or missing, not a glob or async issue.
❓ state_output
advanced1:30remaining
What is the length of documents after loading?
If the 'articles' folder contains 5 text files and you run this code, what is the length of
documents?LangChain
from langchain.document_loaders import DirectoryLoader loader = DirectoryLoader('articles', glob='*.txt') documents = loader.load() print(len(documents))
Attempts:
2 left
💡 Hint
Each file matching the glob creates one Document object.
✗ Incorrect
DirectoryLoader.load() returns one Document per file matched, so length equals number of files.
🧠 Conceptual
expert2:30remaining
Which statement about DirectoryLoader is true?
Select the correct statement about how DirectoryLoader handles files.
Attempts:
2 left
💡 Hint
Think about when file contents are read by DirectoryLoader.
✗ Incorrect
DirectoryLoader.load() reads all matching files immediately and returns a list of Document objects with content.