From 34c8025b56401a17b0c1fad5025db9718e7d5116 Mon Sep 17 00:00:00 2001 From: Admin MPCZ Date: Thu, 16 Apr 2026 14:19:29 +0200 Subject: [PATCH] import_applications_ioda: cast str() pour cellules non-string (int) Le fichier IODA a parfois des integers/floats dans lib_court ou autres cols texte. Helper s() coerce + trim + None si vide. Co-Authored-By: Claude Opus 4.6 (1M context) --- tools/import_applications_ioda.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tools/import_applications_ioda.py b/tools/import_applications_ioda.py index d4468f5..be3957c 100644 --- a/tools/import_applications_ioda.py +++ b/tools/import_applications_ioda.py @@ -53,21 +53,26 @@ def parse_services(xlsx_path): libelle = row[5] if not libelle or not str(libelle).strip(): continue + def s(v): + if v is None: return None + t = str(v).strip() + return t or None + services.append({ "libelle": str(libelle).strip(), - "type": (row[1] or "").strip() if row[1] else None, - "statut": (row[2] or "").strip() if row[2] else None, - "code_pos": (row[3] or "").strip() if row[3] else None, - "lib_court": (row[4] or "").strip() if row[4] else None, - "alias": (row[6] or "").strip() if row[6] else None, - "editeur": (row[7] or "").strip() if row[7] else None, - "description": (row[8] or "").strip() if row[8] else None, - "commentaire": (row[9] or "").strip() if row[9] else None, + "type": s(row[1]), + "statut": s(row[2]), + "code_pos": s(row[3]), + "lib_court": s(row[4]), + "alias": s(row[6]), + "editeur": s(row[7]), + "description": s(row[8]), + "commentaire": s(row[9]), "nb_components": int(row[10]) if row[10] and str(row[10]).strip().isdigit() else None, - "perimetre": (row[11] or "").strip() if row[11] else None, - "dept_domaine": (row[12] or "").strip() if row[12] else None, - "resp_metier": (row[13] or "").strip() if row[13] else None, - "resp_dsi": (row[14] or "").strip() if row[14] else None, + "perimetre": s(row[11]), + "dept_domaine": s(row[12]), + "resp_metier": s(row[13]), + "resp_dsi": s(row[14]), }) return services