@@ -78,7 +78,10 @@ def process(self):
78
78
# guess and set the properties as defined in import_formats.py
79
79
infile = temp_file .open ("r" , encoding = encoding )
80
80
sample = infile .read (1024 * 1024 )
81
- possible_dialects = [csv .Sniffer ().sniff (sample , delimiters = ("," , ";" , "\t " ))]
81
+ try :
82
+ possible_dialects = [csv .Sniffer ().sniff (sample , delimiters = ("," , ";" , "\t " ))]
83
+ except csv .Error :
84
+ possible_dialects = csv .list_dialects ()
82
85
if tool_format .get ("csv_dialect" , {}):
83
86
# Known dialects are defined in import_formats.py
84
87
dialect = csv .Sniffer ().sniff (sample , delimiters = ("," , ";" , "\t " ))
@@ -90,7 +93,7 @@ def process(self):
90
93
# With validated csvs, save as is but make sure the raw file is sorted
91
94
infile .seek (0 )
92
95
dialect = possible_dialects .pop () # Use the last dialect first
93
- self .dataset .log (f"Importing CSV file with dialect: { vars (dialect )} " )
96
+ self .dataset .log (f"Importing CSV file with dialect: { vars (dialect ) if type ( dialect ) == csv . Dialect else dialect } " )
94
97
reader = csv .DictReader (infile , dialect = dialect )
95
98
96
99
if tool_format .get ("columns" ) and not tool_format .get ("allow_user_mapping" ) and set (reader .fieldnames ) & \
0 commit comments