refine text decode (#657)

### What problem does this PR solve?
#651 

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
KevinHuSh 2024-05-07 12:25:47 +08:00 committed by GitHub
parent de839fc3f0
commit 7013d7f620
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 7 additions and 7 deletions

View File

@ -69,7 +69,7 @@ class RAGFlowExcelParser:
if fnm.split(".")[-1].lower() in ["csv", "txt"]:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
return len(txt.split("\n"))

View File

@ -91,7 +91,7 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
txt = ""
if binary:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
else:
with open(filename, "r") as f:
while True:

View File

@ -113,7 +113,7 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
txt = ""
if binary:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
else:
with open(filename, "r") as f:
while True:

View File

@ -141,7 +141,7 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
txt = ""
if binary:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
else:
with open(filename, "r") as f:
while True:

View File

@ -85,7 +85,7 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
txt = ""
if binary:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
else:
with open(filename, "r") as f:
while True:

View File

@ -107,7 +107,7 @@ def chunk(filename, binary=None, lang="Chinese", callback=None, **kwargs):
txt = ""
if binary:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
else:
with open(filename, "r") as f:
while True:

View File

@ -149,7 +149,7 @@ def chunk(filename, binary=None, from_page=0, to_page=10000000000,
txt = ""
if binary:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
else:
with open(filename, "r") as f:
while True: