[Python-checkins] cpython: Issue #29405: Make total calculation in _guess_delimiter more accurate.
xiang.zhang
python-checkins at python.org
Sun Feb 5 21:51:01 EST 2017
https://hg.python.org/cpython/rev/724d1aa7589b
changeset: 106442:724d1aa7589b
user: Xiang Zhang <angwerzx at 126.com>
date: Mon Feb 06 10:50:09 2017 +0800
summary:
Issue #29405: Make total calculation in _guess_delimiter more accurate.
files:
Lib/csv.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Lib/csv.py b/Lib/csv.py
--- a/Lib/csv.py
+++ b/Lib/csv.py
@@ -307,7 +307,7 @@
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 @@
# 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
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list