diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-11-22 21:19:37 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-02-05 10:51:52 +0100 |
commit | 276f05964f44af908947e57604e904fa2710be0a (patch) | |
tree | 0953bce45016e6363ff60674200d1cb55bbdc9a6 /ishtar_common/utils.py | |
parent | fbc5432ef632082645b3d3961b5332a21f0f1da1 (diff) | |
download | Ishtar-276f05964f44af908947e57604e904fa2710be0a.tar.bz2 Ishtar-276f05964f44af908947e57604e904fa2710be0a.zip |
🐛 import - extract data from xls, ods, etc. with pandas instead of LO
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 5cc5d0363..cf56ea705 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -30,6 +30,7 @@ import io from jinja2 import Template import locale import math +import numpy import os import random import re @@ -1223,6 +1224,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] |