bpo-43625: Enhance csv sniffer has_headers() to be more accurate (GH-26939)

This commit is contained in:
andrei kulakov 2021-07-30 13:10:37 -04:00 committed by GitHub
parent e3f877c32d
commit ceea579ccc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 8 deletions

View file

@ -409,14 +409,10 @@ class Sniffer:
continue # skip rows that have irregular number of columns
for col in list(columnTypes.keys()):
for thisType in [int, float, complex]:
try:
thisType(row[col])
break
except (ValueError, OverflowError):
pass
else:
thisType = complex
try:
thisType(row[col])
except (ValueError, OverflowError):
# fallback to length of string
thisType = len(row[col])