Find answers from the community

Updated 3 months ago

i have a list containing multiple texts,, how to load this list into Document?

i have a list containing multiple texts,, how to load this list into Document?
k
2 comments
Please stand by @ChatGPT-fan as I search the knowledge base. I normally take about 20 seconds or so. :wave:
----------------------
You can load a list of texts into Document objects using the Document struct exposed by LlamaIndex. Here is a simple code snippet that demonstrates how to do this:

Plain Text
from llama_index.core import Document

text_list = [text1, text2, ...]  # replace with your list of texts
documents = [Document(text=t) for t in text_list]


In this code, text_list is your list of texts. The list comprehension [Document(text=t) for t in text_list] creates a new Document object for each text in your list, and stores these Document objects in the documents list.

For more details, you can refer to the LlamaIndex documentation ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Add a reply
Sign up and join the conversation on Discord