Commit 00accf5c303b16ce47da6fa2f861ee68e3d08da8
1 parent
30f77ee9
Exists in
master
fix: allow CSV delimited by ;
This is a monkey fix, and we're not supporting tabs either.
Showing
1 changed file
with
6 additions
and
4 deletions
Show diff stats
flaskr/controllers/main_controller.py
@@ -88,9 +88,11 @@ def gather_addresses(from_list, from_file): | @@ -88,9 +88,11 @@ def gather_addresses(from_list, from_file): | ||
88 | rows_dicts = None | 88 | rows_dicts = None |
89 | 89 | ||
90 | if 'text/csv' == file_mimetype: | 90 | if 'text/csv' == file_mimetype: |
91 | - | 91 | + delimiter = ',' |
92 | + if ';' in file_contents: | ||
93 | + delimiter = ';' | ||
92 | rows_dicts = pandas \ | 94 | rows_dicts = pandas \ |
93 | - .read_csv(StringIO(file_contents)) \ | 95 | + .read_csv(StringIO(file_contents), delimiter=delimiter) \ |
94 | .rename(str.lower, axis='columns') \ | 96 | .rename(str.lower, axis='columns') \ |
95 | .to_dict(orient="row") | 97 | .to_dict(orient="row") |
96 | 98 | ||
@@ -194,7 +196,7 @@ def estimate(): # register new estimation request, more accurately | @@ -194,7 +196,7 @@ def estimate(): # register new estimation request, more accurately | ||
194 | form.origin_addresses_file.data | 196 | form.origin_addresses_file.data |
195 | ) | 197 | ) |
196 | except validators.ValidationError as e: | 198 | except validators.ValidationError as e: |
197 | - form.origin_addresses_file.errors.append(e.message) | 199 | + form.origin_addresses_file.errors.append(str(e)) |
198 | return show_form() | 200 | return show_form() |
199 | 201 | ||
200 | try: | 202 | try: |
@@ -203,7 +205,7 @@ def estimate(): # register new estimation request, more accurately | @@ -203,7 +205,7 @@ def estimate(): # register new estimation request, more accurately | ||
203 | form.destination_addresses_file.data | 205 | form.destination_addresses_file.data |
204 | ) | 206 | ) |
205 | except validators.ValidationError as e: | 207 | except validators.ValidationError as e: |
206 | - form.destination_addresses_file.errors.append(e.message) | 208 | + form.destination_addresses_file.errors.append(str(e)) |
207 | return show_form() | 209 | return show_form() |
208 | 210 | ||
209 | estimation.use_train_below_km = form.use_train_below_km.data | 211 | estimation.use_train_below_km = form.use_train_below_km.data |