manager: use csv-dialect that's been detected

This commit is contained in:
Frédéric Péters 2016-09-16 15:22:27 +02:00
parent 85a64b6a52
commit 6290336343
1 changed files with 3 additions and 2 deletions

View File

@ -72,6 +72,7 @@ class ImportEventsForm(forms.Form):
help_text=_('CSV file with date, time, number of places, '
'number of places in waiting list, and label '
'as columns.'))
events = None
def clean_events_csv_file(self):
content = self.cleaned_data['events_csv_file'].read()
@ -80,11 +81,11 @@ class ImportEventsForm(forms.Form):
try:
dialect = csv.Sniffer().sniff(content)
except Exception:
except csv.Error:
dialect = None
events = []
for i, csvline in enumerate(csv.reader(content.splitlines())):
for i, csvline in enumerate(csv.reader(content.splitlines(), dialect=dialect)):
if not csvline:
continue
if len(csvline) < 2: