forked from Archives/langchain
Update text.py (#2195)
Add encoding parameter when open txt file to support unicode files.
This commit is contained in:
parent
5d86a6acf1
commit
64b9843b5b
@ -14,7 +14,7 @@ class TextLoader(BaseLoader):
|
|||||||
|
|
||||||
def load(self) -> List[Document]:
|
def load(self) -> List[Document]:
|
||||||
"""Load from file path."""
|
"""Load from file path."""
|
||||||
with open(self.file_path) as f:
|
with open(self.file_path, encoding="utf-8") as f:
|
||||||
text = f.read()
|
text = f.read()
|
||||||
metadata = {"source": self.file_path}
|
metadata = {"source": self.file_path}
|
||||||
return [Document(page_content=text, metadata=metadata)]
|
return [Document(page_content=text, metadata=metadata)]
|
||||||
|
Loading…
Reference in New Issue
Block a user