GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — csv.Sniffer uses a heuristic to determine doublequote that is often false-negative · Issue #109339 · python/cpython Open Labels stdlibStandard 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 DescriptionBug reportBug description:The current heuristic is as follows: dq_regexp = re.compile(...) # some regex that matches more than two quotation marks between delimiters if dq_regexp.search(data): doublequote = True else: doublequote = False That is, if the sample doesn't contain doubled quotation marks, it is assumed that the whole file doesn't either. However, such assumption is likely to be false: many CSV files only have a few quotation marks that need escaping, and a small sample is likely to include none. Moreover, all the built-in dialects ( bq_regexp = re.compile(...) # some regex that matches a backslash-followed-by-quotation-mark if bq_regexp.search(data): # an attempt was made to escape a quotation mark with escapechar, # so the writer clearly was not relying on doublequotes doublequote = False else: doublequote = True # don't know, but consider True a safe default Also, the current heuristic can already yield false-positive results as well: In fact, nothing in this sample indicates that the writer was doubling quotation marks, however it doesn't hurt: it can be parsed with either value of CPython versions tested on:3.11 Operating systems tested on:No response Activity
MetadataMetadataAssigneesLabelsstdlibStandard 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
MilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |