Skip to content

Commit

Permalink
Update _csv.py
Browse files Browse the repository at this point in the history
Doubling the stream read sample in detect() from 1024 to 2048 to make csv.Sniffer().sniff() more reliable.
  • Loading branch information
julianebeli authored Oct 14, 2021
1 parent ebd916e commit 942ed76
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/tablib/formats/_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def import_set(cls, dset, in_stream, headers=True, skip_lines=0, **kwargs):
def detect(cls, stream, delimiter=None):
"""Returns True if given stream is valid CSV."""
try:
csv.Sniffer().sniff(stream.read(1024), delimiters=delimiter or cls.DEFAULT_DELIMITER)
csv.Sniffer().sniff(stream.read(2048), delimiters=delimiter or cls.DEFAULT_DELIMITER)
return True
except Exception:
return False

0 comments on commit 942ed76

Please sign in to comment.