diff options
author | Xiang Zhang <angwerzx@126.com> | 2017-02-06 10:50:09 +0800 |
---|---|---|
committer | Xiang Zhang <angwerzx@126.com> | 2017-02-06 10:50:09 +0800 |
commit | 1ebed331c127c8ca4a279c5121cfd4a9de3cfda8 (patch) | |
tree | 2de40f687ac814b0256567aaa85e17cba5c26fb4 | |
parent | 6ab2547ee1e19cb33ef5c3e7f60495fbd5e89cef (diff) | |
download | cpython-1ebed331c127c8ca4a279c5121cfd4a9de3cfda8.tar.gz |
Issue #29405: Make total calculation in _guess_delimiter more accurate.
-rw-r--r-- | Lib/csv.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/csv.py b/Lib/csv.py index 0349e0bd11..6a8587674f 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 |