From e17acb8c6b1c740f0b051e182e540c53f4256333 Mon Sep 17 00:00:00 2001 From: "Michael J.M. Wagner" Date: Mon, 26 Feb 2024 18:22:28 +0100 Subject: [PATCH] posaune --- python/sv-merger/sv-merger.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) mode change 100644 => 100755 python/sv-merger/sv-merger.py diff --git a/python/sv-merger/sv-merger.py b/python/sv-merger/sv-merger.py old mode 100644 new mode 100755 index 52c654e..7e3c1e5 --- a/python/sv-merger/sv-merger.py +++ b/python/sv-merger/sv-merger.py @@ -1,3 +1,4 @@ +#!/usr/bin/python3 ''' Created on 10.01.2024 @@ -28,7 +29,8 @@ sv_such_spalte = -1 i = 0 for kopf in export_header: - kopf = kopf[1:-1] + if kopf[0] == '"': + kopf = kopf[1:-1] if kopf == 'Freifeldwert_1': sv_pn_spalte = i if kopf == sys.argv[3]: @@ -64,15 +66,27 @@ for line in dh_delta: if len(line.rstrip()): # not a empty line data = line.split(";") - delta[data[delta_pn_sp]] = data[delta_such_sp] + if len(data[delta_pn_sp]) == 0: + print("Diese Zeile hat keine Migliedsnummer: ", line) + else: + delta[int(data[delta_pn_sp])] = data[delta_such_sp] for line in dh_export: data = line.rstrip().split(";") - pn = data[sv_pn_spalte][1:-1] - if pn in delta: - if len(delta[pn]): - data[sv_such_spalte] = delta[pn] - print(";".join(data), file=dh_import) + pn = data[sv_pn_spalte] + if len(pn) == 0: + print("Diese Zeile (export) hat keine Migliedsnummer: ", line) + else: + if pn[0] == '"': + pn = pn[1:-1] + pn = int(pn) + if pn in delta: + if len(delta[pn]): + if data[sv_such_spalte] != delta[pn]: + data[sv_such_spalte] = delta[pn] + print(";".join(data), file=dh_import) + else: + print(f"{pn} fehlt in delta-Datei") dh_export.close() dh_delta.close() -- 2.20.1