From ed2f71c15016e3bfeb295824d9bb58791c69ec9e Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 21 Oct 2020 22:09:15 +0200 Subject: [PATCH] add delimeter as ; in csv --- ereuse_devicehub/resources/documents/documents.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/resources/documents/documents.py b/ereuse_devicehub/resources/documents/documents.py index 53bd8d82..e65bee81 100644 --- a/ereuse_devicehub/resources/documents/documents.py +++ b/ereuse_devicehub/resources/documents/documents.py @@ -117,7 +117,7 @@ class DevicesDocumentView(DeviceView): def generate_post_csv(self, query): """Get device query and put information in csv format.""" data = StringIO() - cw = csv.writer(data) + cw = csv.writer(data, delimiter=';', quotechar='"') first = True for device in query: d = DeviceRow(device) @@ -125,7 +125,7 @@ class DevicesDocumentView(DeviceView): cw.writerow(d.keys()) first = False cw.writerow(d.values()) - output = make_response(data.getvalue()) + output = make_response(data.getvalue().encode('utf-8')) output.headers['Content-Disposition'] = 'attachment; filename=export.csv' output.headers['Content-type'] = 'text/csv' return output