Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
CSV sniffing detects wrong field delimiter #97611
Copy link
Copy link
Open
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
StatusShow more project fields
Done
Bug report
csv.Sniffer().sniff()detects the wrong field delimiter if the possible valid delimiters contain\tand 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\tinstead of the correct one.Configuring the preferred separator as suggested in #80678 (comment) doesn't have any effect on this behavior.
Here is an example to reproduce it:
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