mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-30 04:29:24 +08:00
Fix tag CSV parser splicing wrong text after a multi-line quoted field (#17131)
This commit is contained in:
@@ -96,12 +96,16 @@ def chunk(filename, binary=None, lang="Chinese", callback=None, **kwargs):
|
||||
fails = []
|
||||
content = ""
|
||||
res = []
|
||||
reader = csv.reader(lines)
|
||||
reader = csv.reader((line + "\n" for line in lines))
|
||||
prev_line_num = 0
|
||||
|
||||
# line_num tracks the physical span when quoted fields cross lines.
|
||||
for i, row in enumerate(reader):
|
||||
raw = "\n".join(lines[prev_line_num : reader.line_num])
|
||||
prev_line_num = reader.line_num
|
||||
row = [r.strip() for r in row if r.strip()]
|
||||
if len(row) != 2:
|
||||
content += "\n" + lines[i]
|
||||
content += "\n" + raw
|
||||
elif len(row) == 2:
|
||||
content += "\n" + row[0]
|
||||
res.append(beAdoc(deepcopy(doc), content, row[1], eng, i))
|
||||
|
||||
Reference in New Issue
Block a user