Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6aee6fb

Browse files
committed
Issue #29405: Make total calculation in _guess_delimiter more accurate.
1 parent 9735384 commit 6aee6fb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/csv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def _guess_delimiter(self, data, delimiters):
307307
charFrequency = {}
308308
modes = {}
309309
delims = {}
310-
start, end = 0, min(chunkLength, len(data))
310+
start, end = 0, chunkLength
311311
while start < len(data):
312312
iteration += 1
313313
for line in data[start:end]:
@@ -336,7 +336,7 @@ def _guess_delimiter(self, data, delimiters):
336336

337337
# build a list of possible delimiters
338338
modeList = modes.items()
339-
total = float(chunkLength * iteration)
339+
total = float(min(chunkLength * iteration, len(data)))
340340
# (rows of consistent data) / (number of rows) = 100%
341341
consistency = 1.0
342342
# minimum consistency threshold

0 commit comments

Comments
 (0)