From 730de9cc7f521a4a444daf42675e5e7b5260a377 Mon Sep 17 00:00:00 2001 From: Yash Raj Pandey <55940078+devYRPauli@users.noreply.github.com> Date: Tue, 28 Jul 2026 05:04:11 -0400 Subject: [PATCH] Fix tag CSV parser splicing wrong text after a multi-line quoted field (#17131) --- rag/app/tag.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rag/app/tag.py b/rag/app/tag.py index 2c3a27785e..656226a792 100644 --- a/rag/app/tag.py +++ b/rag/app/tag.py @@ -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))