[BUG] CSV delimiter detection splits quoted semicolons into columns
Description
The spreadsheet reader can misdetect a valid comma-separated CSV as semicolon-separated when quoted text cells contain several semicolons. The resulting grid has the wrong columns, and the rows query treats the first data record as a header and reports two records instead of three.
This was found during source inspection and reproduced locally with generated CSV bytes. It is not a claim about a production incident.
Steps to Reproduce
from crewai_files.spreadsheets.reading import parse
from crewai_files.spreadsheets.answers import Query, query
data = b'id,note\n1,"a;b;c;d"\n2,"e;f;g;h"\n3,"i;j;k;l"\n'
book = parse(data, "example.csv")
print(book.sheets[0].grid)
print(query(book, "example.csv", Query(operation="rows")))
Expected behavior
The grid should contain the header ["id", "note"] and three two-cell data rows. Each note should retain its quoted semicolons as cell content. The rows query should show all three records.
Screenshots/Code snippets
Actual grid
[
["id,note"],
['1,"a', "b", "c", 'd"'],
['2,"e', "f", "g", 'h"'],
['3,"i', "j", "k", 'l"'],
]
The query reports two rows and uses the first data row as column names. A normal comma CSV without semicolons in the notes and a normal semicolon CSV both parse correctly in the same environment.
Operating System
Windows x86_64
Python Version
3.12.14
crewAI Version
crewai-files 1.15.44, editable source checkout at 56c26a7fb3ece62c64de52e8b4228d15c9c81492. The core crewai package is not needed for this reproduction.
crewAI Tools Version
Not installed or needed.
Virtual Environment
uv-created virtual environment.
Evidence
The snippet uses the real installed package with normal imports. No parser replacement, model call, API key or network service is involved. The unmodified reading and answers test modules pass locally, 155 tests, so the existing examples do not catch this case.
Possible Solution
_sniff_delimiter scores each candidate as the modal field count multiplied by its occurrence count. A wrong delimiter that produces four fields on two sampled rows scores above the correct delimiter producing two fields on three rows. Prefer consistency across sampled records before field count, while preserving the existing European decimal-comma and separator controls. I can contribute a scoped regression-tested fix.
Additional context
This investigation and report were prepared and executed with Codex assistance. The contribution guide requires the llm-generated label. It is requested with this issue, and if GitHub omits it due to contributor permissions, please apply it before review. Account-owner review is not claimed.
Thanks for the clear reproduction, @duoduohappy. I’m planning to pick this up. I’ll look into the delimiter scoring and check that a fix preserves semicolon-delimited CSVs with decimal commas.
Thanks for picking this up and opening #9649. Preserving semicolon-delimited CSVs with decimal commas is an important compatibility check. I'll follow the PR discussion to avoid duplicating the work.
Thanks for the report, @duoduohappy. I'm closing this as not planned.
Thanks for the update. Could you clarify why this is not planned—for example, whether this behavior is considered acceptable or the fix is outside the current scope? That would help me understand the expected behavior and guide future contributions.