From 5920a59c48fe8dfb1b458b3d90773606f4f383bd Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 22 Nov 2023 21:19:37 +0100 Subject: 🐛 import - extract data from xls, ods, etc. with pandas instead of LO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ishtar_common/utils.py') diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index e0a670d56..35289145c 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -31,6 +31,7 @@ from jinja2 import Template from jinja2.filters import FILTERS, environmentfilter import locale import math +import numpy import os import random import re @@ -1224,6 +1225,21 @@ def _post_save_geo(sender, **kwargs): return +def format_int_float(values): + """ + Numpy array: format integer with not "." + """ + new_values = [] + for value in values: + if numpy.isnan(value): + new_values.append("") + elif int(value) == value: + new_values.append(str(int(value))) + else: + new_values.append(value) + return new_values + + def create_slug(model, name, slug_attr="slug", max_length=100): base_slug = slugify(name) slug = base_slug[:max_length] -- cgit v1.2.3