Show sniffed delimiter on exception (or when `--verbose`)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Start with the csvstat command and the referenced agate/csv_py3.py sampling code at line 153, then reproduce the 10-row and 100-row examples from the issue. Trace how the delimiter and SNIFF_LIMIT are handled, including verbose output and the row-width exception. Done means the selected delimiter is visible in the requested debug or error output, with an excess-SNIFF_LIMIT warning when applicable.
Written by the indexing model from the issue text.
Description
# colA,colB
# aaaaa...aaaaa zzzzz...zzzzz \
# ... } 10 or 100 rows
# aaaaa...aaaaa zzzzz...zzzzz /
#
# \___________/ \___________/
# 1000chars 1000chars
# 10 rows
# "," is used as delimiter
python3 -c "print('colA,colB') ; [print('a'*1000 + ' ' + 'z'*1000) for _ in range(10)]" | csvstat
# => ok
# 100 rows
# " " is used as delimiter
python3 -c "print('colA,colB') ; [print('a'*1000 + ' ' + 'z'*1000) for _ in range(100)]" | csvstat
# => Row 0 has 3 values, but Table only has 2 columns.
In the latter case, sample is trimmed, losing the header colA,colB, thus white space " " is used as the delimiter.
It was tough for me to figure out this behavior. So how about showing "what delimiter is used" in:
- Debug output
$ csvstat -v ...
inferred delimiter: ' '
- Error message
$ csvstat -v ...
Row 0 has 3 values, but Table only has 2 columns (delimiter: ' ').
and, how about showing warning of excessing SNIFF_LIMIT?:
$ csvstat -v ...
warning: input (XXX bytes) exceeds SNIFF_LIMIT (YYY bytes), delimiter guessing may be incorrect (NOTE: SNIFF_LIMIT can be changed by -y flag)
warning: guessed delimiter: ' '
Row 0 has 3 values, but Table only has 2 columns.
- Dominant language
- Python
- Stars
- 6.4k
- Forks
- 689
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from wireservice/csvkit
-
feature framework
Difficulty 3/5 1-2 days Newbie friendliness 45/100
wireservice/csvkit#1344 ·
-
csvlook feature
Difficulty 4/5 3-5 days Newbie friendliness 35/100
wireservice/csvkit#1313 · 2 comments ·
-
csvclean feature
Difficulty 4/5 3-5 days Newbie friendliness 35/100
wireservice/csvkit#1290 · 3 comments ·
-
question
Difficulty 3/5 1-2 days Newbie friendliness 45/100
wireservice/csvkit#1289 · 4 comments ·
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
wireservice/csvkit#1279 · 2 comments ·
All issues in wireservice/csvkit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100