CSV sniffing detects wrong field delimiter
まだ誰も着手していません。
評価
この issue はまだ評価されていません。
説明
Bug report
csv.Sniffer().sniff() detects the wrong field delimiter if the possible valid delimiters contain \t and the provided data contains one line starting with the combination of double quotes followed by a tab and has the same combination of double quotes and a tab at least once more afterwards in the data. In that case the delimiter is always reported as \t instead of the correct one.
Configuring the preferred separator as suggested in https://github.com/python/cpython/issues/80678#issuecomment-1093819685 doesn't have any effect on this behavior.
Here is an example to reproduce it:
import csv
from pprint import pprint
data = """
Surname;First Name;Year of birth
"\tDoe;Jane"\t;1971
"""
sniffer = csv.Sniffer()
dialect = sniffer.sniff(data, delimiters=",;\t")
pprint(dict(dialect.__dict__))
Expected output:
{'__doc__': None,
'__module__': 'csv',
'_name': 'sniffed',
'delimiter': ';',
'doublequote': False,
'lineterminator': '\r\n',
'quotechar': '"',
'quoting': 0,
'skipinitialspace': False}
Actual output:
{'__doc__': None,
'__module__': 'csv',
'_name': 'sniffed',
'delimiter': '\t',
'doublequote': False,
'lineterminator': '\r\n',
'quotechar': '"',
'quoting': 0,
'skipinitialspace': False}
Your environment
- CPython versions tested on: 3.7.14, 3.8.14, 3.9.14, 3.10.7
- Operating system and architecture: Debian/sid on amd64
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 558
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/cpython のほかの issue
-
docs pending
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
stdlib type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
stdlib type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
build type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
stdlib topic-email type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
🐛 Bug 🔔 Pending processing
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
jumpserver/jumpserver#17584 ·