Find answers from the community

Updated 2 months ago

```# Load documentsdocuments = SimpleDirectoryReader("/content/data/paul_graham", recursi

Plain Text
# Load documents
documents = SimpleDirectoryReader("/content/data/paul_graham", recursive=True).load_data()
gives error:
Plain Text
ValueError                                Traceback (most recent call last)
<ipython-input-7-0bfb093e8ab6> in <cell line: 14>()
     12 
     13 # Load documents
---> 14 documents = SimpleDirectoryReader("/content/data/paul_graham", recursive=True).load_data()
     15 
     16 # Create an index from the documents using the service context

1 frames
/usr/local/lib/python3.10/dist-packages/llama_index/core/readers/file/base.py in _add_files(self, input_dir)
    303 
    304         if len(new_input_files) == 0:
--> 305             raise ValueError(f"No files found in {input_dir}.")
    306 
    307         if self.num_files_limit is not None and self.num_files_limit > 0:

ValueError: No files found in /content/data/paul_graham.
k
W
a
6 comments
Please stand by @andysingal as I search the knowledge base. I normally take about 20 seconds or so. :wave:
----------------------
The error message you're seeing indicates that no files were found in the directory /content/data/paul_graham. This could be due to a few reasons:

  1. The directory does not exist. Make sure that the directory /content/data/paul_graham exists in your file system.
  1. The directory exists but is empty. Ensure that there are files within the directory that match the file extensions you're looking to load.
  1. The directory exists and contains files, but the files do not match the required extensions. If you've specified required_exts in SimpleDirectoryReader, make sure the files in the directory have the correct extensions.
Here's an example of how you can load documents from a directory using SimpleDirectoryReader:

Plain Text
from llama_index.core import SimpleDirectoryReader

# Load all (recursive) files from directory
reader = SimpleDirectoryReader(input_dir="/content/data/paul_graham", recursive=True)
documents = reader.load_data()


In this example, SimpleDirectoryReader is initialized with the directory path and recursive=True to load files from subdirectories as well. Then, load_data() is called to load the documents from the specified directory.

If you're still encountering issues, you might want to check the contents of your directory to ensure it contains the expected files. You can do this with a command like !ls /content/data/paul_graham in a notebook or ls /content/data/paul_graham in a terminal.
Sources:
  • Simple Directory Reader ()
  • HoneyHive LlamaIndex Tracer ()
  • Epsilla Vector Store ()
  • CohereAI Embeddings ()
  • Redis Docstore+Index Store Demo ()
  • Instrumentation: Basic Usage ()
  • Ollama Llama Pack Example ()
  • Azure AI Search ()
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Can you check if there exist any files in the specified folder?
This is a better snapshot @WhiteFang_Jr
Attachment
Screenshot_2024-03-28_at_5.49.18_PM.png
Just checked, it is considering if you pass "/content" only but nothing if you pass anything else in there
Add a reply
Sign up and join the conversation on Discord