diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-11-22 21:19:37 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-04-16 16:38:32 +0200 |
commit | 5920a59c48fe8dfb1b458b3d90773606f4f383bd (patch) | |
tree | 65bd5ad4870fbf93f283a0819ac42acaf45f71b5 /ishtar_common/utils.py | |
parent | 985b1730d022adc90b6213141251ddaaa1947696 (diff) | |
download | Ishtar-5920a59c48fe8dfb1b458b3d90773606f4f383bd.tar.bz2 Ishtar-5920a59c48fe8dfb1b458b3d90773606f4f383bd.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 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] |