From 64b9843b5ba7e97b15f0324e7a5e0f4066aa4d31 Mon Sep 17 00:00:00 2001 From: Jeru2023 <123569003+Jeru2023@users.noreply.github.com> Date: Thu, 30 Mar 2023 22:52:17 +0800 Subject: [PATCH] Update text.py (#2195) Add encoding parameter when open txt file to support unicode files. --- langchain/document_loaders/text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain/document_loaders/text.py b/langchain/document_loaders/text.py index 6962833a..0284de88 100644 --- a/langchain/document_loaders/text.py +++ b/langchain/document_loaders/text.py @@ -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)]