From: Xiang Zhang Date: Mon, 6 Feb 2017 02:50:09 +0000 (+0800) Subject: Issue #29405: Make total calculation in _guess_delimiter more accurate. X-Git-Tag: v3.7.0a1~1406 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6aee6fbce8f3d7b8c8eae5d8f88fc2282698a6dc;p=thirdparty%2FPython%2Fcpython.git Issue #29405: Make total calculation in _guess_delimiter more accurate. --- diff --git a/Lib/csv.py b/Lib/csv.py index 0349e0bd1162..6a8587674fe0 100644 --- a/Lib/csv.py +++ b/Lib/csv.py @@ -307,7 +307,7 @@ class Sniffer: charFrequency = {} modes = {} delims = {} - start, end = 0, min(chunkLength, len(data)) + start, end = 0, chunkLength while start < len(data): iteration += 1 for line in data[start:end]: @@ -336,7 +336,7 @@ class Sniffer: # build a list of possible delimiters modeList = modes.items() - total = float(chunkLength * iteration) + total = float(min(chunkLength * iteration, len(data))) # (rows of consistent data) / (number of rows) = 100% consistency = 1.0 # minimum consistency threshold