Skip to content
Open
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
80be530
do not iterate over all ascii
maurycy Aug 11, 2025
2d636cf
NEWS entry
maurycy Aug 11, 2025
1f0b25e
bring back the comment
maurycy Aug 11, 2025
601b2f1
bang
maurycy Aug 11, 2025
2dc0d41
document the public method
maurycy Aug 11, 2025
f106da2
import within Sniffer
maurycy Aug 11, 2025
7f7dca1
Merge branch 'main' into csv-sniffer-counter-set
maurycy Aug 11, 2025
2f1ea73
_ASCII_CHARS, set operators
maurycy Aug 11, 2025
4b50610
Merge branch 'main' into csv-sniffer-counter-set
maurycy Aug 13, 2025
07a336b
update docs, no set operations
maurycy Aug 13, 2025
080dbfc
Merge branch 'main' into csv-sniffer-counter-set
maurycy Aug 15, 2025
0b5bcdd
Merge branch 'main' into csv-sniffer-counter-set
maurycy Aug 17, 2025
2ccaac0
Update Lib/csv.py
maurycy Aug 18, 2025
36fc9d9
move whatsnew to Optimizations
maurycy Aug 18, 2025
7189b51
s/seen/num_lines/
maurycy Aug 18, 2025
6b64ba4
picnixz suggestion
maurycy Aug 18, 2025
4b62c84
use isascii
maurycy Aug 18, 2025
dcbd9f5
CRLF tie
maurycy Aug 19, 2025
14ea139
simple tie test
maurycy Aug 19, 2025
c332fb4
rm assert
maurycy Aug 19, 2025
e5b5611
update the benchmark numbers
maurycy Aug 19, 2025
8614756
Merge branch 'main' into csv-sniffer-counter-set
maurycy Aug 19, 2025
a95b16a
Update Lib/test/test_csv.py
maurycy Aug 28, 2025
59c9395
vs
maurycy Aug 28, 2025
3e7beaa
Update Doc/whatsnew/3.15.rst
maurycy Aug 28, 2025
c9cd73e
Update Lib/csv.py
maurycy Aug 28, 2025
7a3c974
,: tie
maurycy Aug 30, 2025
cecb897
be consistent
maurycy Aug 30, 2025
ab871e0
check the exc msg
maurycy Aug 30, 2025
5181f5d
Update Lib/test/test_csv.py
maurycy Aug 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
s/seen/num_lines/
  • Loading branch information
maurycy committed Aug 18, 2025
commit 7189b5112316c5f18b259c8d8aec320a1fcb5ad4
6 changes: 3 additions & 3 deletions Lib/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def _guess_delimiter(self, data, delimiters):
# build frequency tables
chunkLength = min(10, len(data))
iteration = 0
seen = 0
num_lines = 0
# {char -> {count_per_line -> num_lines_with_that_count}}
charFrequency = defaultdict(Counter)
modes = {}
Expand All @@ -380,14 +380,14 @@ def _guess_delimiter(self, data, delimiters):
while start < len(data):
iteration += 1
for line in data[start:end]:
seen += 1
num_lines += 1
for char, count in Counter(line).items():
if ord(char) < 127:
charFrequency[char][count] += 1

for char, counts in charFrequency.items():
presentCount = sum(counts.values())
zeroCount = seen - presentCount
zeroCount = num_lines - presentCount
if zeroCount > 0:
items = list(counts.items()) + [(0, zeroCount)]
else:
Expand Down
Loading