Find answers from the community

Updated 2 months ago

does CSVReader exist in llama_index:

does CSVReader exist in llama_index:
from llama_index.core.readers import CSVReader
L
C
7 comments
from llama_index.readers.file import CSVReader
@Logan M is this right way of importing this:
from llama_index.core.storage import StorageContext, VectorStoreIndex, load_index_from_storage
Remove .storage from the import path
am getting this error for hours any help annoying errorrrs :(!) Traceback (most recent call last): File "/Users/ahmednadiir/Desktop/agency/app.py", line 11, in <module> from quran import quran_engine File "/Users/ahmednadiir/Desktop/agency/quran.py", line 21, in <module> quran_csv = CSVReader().load_data(file=csv_path); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahmednadiir/Desktop/agency/localEvir/lib/python3.11/site-packages/llama_index/readers/file/tabular/base.py", line 48, in load_data return [Document(text="\n".join(text_list), metadata=extra_info)] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/ahmednadiir/Desktop/agency/localEvir/lib/python3.11/site-packages/pydantic/v1/main.py", line 341, in __init__ raise validation_error pydantic.v1.error_wrappers.ValidationError: 1 validation error for Document extra_info none is not an allowed value (type=type_error.none.not_allowed)

my code:
import os from llama_index.core import StorageContext, VectorStoreIndex, load_index_from_storage from llama_index.readers.file import CSVReader def get_index(data, index_name): index = None if not os.path.exists(index_name): print("building index", index_name) index = VectorStoreIndex.from_documents(data, show_progress=True) index.storage_context.persist(persist_dir=index_name) else: index = load_index_from_storage( StorageContext.from_defaults(persist_dir=index_name) ) return index csv_path = os.path.join("data", "quran-english-tafsir.csv"); quran_csv = CSVReader().load_data(file=csv_path); quran_index = get_index(quran_csv, "quran") quran_engine = quran_index.as_query_engine() quran_engine.query()
Add a reply
Sign up and join the conversation on Discord