CSV sniffing detects wrong field delimiter
Chưa có ai nhận issue này.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 558
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python/cpython
-
docs pending
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
stdlib type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
stdlib type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
build type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
stdlib topic-email type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Tất cả issue của python/cpython
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
🐛 Bug 🔔 Pending processing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
jumpserver/jumpserver#17584 ·