From 00accf5c303b16ce47da6fa2f861ee68e3d08da8 Mon Sep 17 00:00:00 2001 From: Antoine Goutenoir Date: Sat, 22 May 2021 10:10:33 +0200 Subject: [PATCH] fix: allow CSV delimited by ; --- flaskr/controllers/main_controller.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/flaskr/controllers/main_controller.py b/flaskr/controllers/main_controller.py index 43e97ce..e129026 100644 --- a/flaskr/controllers/main_controller.py +++ b/flaskr/controllers/main_controller.py @@ -88,9 +88,11 @@ def gather_addresses(from_list, from_file): rows_dicts = None if 'text/csv' == file_mimetype: - + delimiter = ',' + if ';' in file_contents: + delimiter = ';' rows_dicts = pandas \ - .read_csv(StringIO(file_contents)) \ + .read_csv(StringIO(file_contents), delimiter=delimiter) \ .rename(str.lower, axis='columns') \ .to_dict(orient="row") @@ -194,7 +196,7 @@ def estimate(): # register new estimation request, more accurately form.origin_addresses_file.data ) except validators.ValidationError as e: - form.origin_addresses_file.errors.append(e.message) + form.origin_addresses_file.errors.append(str(e)) return show_form() try: @@ -203,7 +205,7 @@ def estimate(): # register new estimation request, more accurately form.destination_addresses_file.data ) except validators.ValidationError as e: - form.destination_addresses_file.errors.append(e.message) + form.destination_addresses_file.errors.append(str(e)) return show_form() estimation.use_train_below_km = form.use_train_below_km.data -- libgit2 0.21.2