mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
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]:
|
||||
"""Load from file path."""
|
||||
with open(self.file_path) as f:
|
||||
with open(self.file_path, encoding="utf-8") as f:
|
||||
text = f.read()
|
||||
metadata = {"source": self.file_path}
|
||||
return [Document(page_content=text, metadata=metadata)]
|
||||
|
Loading…
Reference in New Issue
Block a user