csv importer: mimic messytables defaults for now

This commit is contained in:
Yohan Boniface 2022-09-20 17:28:46 +02:00
parent 2544736aa8
commit 57c8f9f4fe

View File

@ -108,6 +108,9 @@ def _guess_dialect(file_obj):
# Restrict allowed delimiters to prevent guessing other char than this list. # Restrict allowed delimiters to prevent guessing other char than this list.
dialect = csv.Sniffer().sniff(file_obj.read(100000), delimiters=['\t', ',', ';', '|']) dialect = csv.Sniffer().sniff(file_obj.read(100000), delimiters=['\t', ',', ';', '|'])
log.info("Guessed dialect %s" % dict(dialect.__dict__)) log.info("Guessed dialect %s" % dict(dialect.__dict__))
# Mimic messytables default for now.
dialect.lineterminator = "\n"
dialect.doublequote = True
return dialect return dialect
except csv.Error: except csv.Error:
log.info("Cannot guess dialect using Excel as fallback.") log.info("Cannot guess dialect using Excel as fallback.")