From 6ce225ba91ddd930d673481c8cf37defa75b4c6d Mon Sep 17 00:00:00 2001 From: Juergen Lipp Date: Mon, 11 Mar 2024 13:48:07 +0100 Subject: [PATCH] Update ascii doc link, fixed empty data in measurements --- README.md | 2 +- aqdefreader/file.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9ecec73..2b25da6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ parts (Teiletyp) and characteristics (Merkmale). As the ASCII files might alread them as part of the characteristics described in the transfer file. The package `aqdefreader` is based on the official -[Q-DAS ASCII transfer format manual](https://www.q-das.com/fileadmin/mediamanager/Datenformat_Dokumente/Q-DAS_ASCII-Transfer-Format_ENG_V12_ec.pdf) tranfer format released by Q-DAS GmbH. +[Q-DAS ASCII transfer format manual](https://training.q-das.de/fileadmin/mediamanager/Datenformat_Dokumente/Q-DAS_ASCII-Transfer-Format_ENG_V12_ec.pdf) tranfer format released by Q-DAS GmbH. ## Installation The source code is currently hosted on GitHub at: diff --git a/aqdefreader/file.py b/aqdefreader/file.py index c46d1c1..67f5b22 100644 --- a/aqdefreader/file.py +++ b/aqdefreader/file.py @@ -26,7 +26,6 @@ def __init__(self, lines): self.__error_count = 0 self.__get_lines(lines) - print("something") def __get_lines(self, lines): for line in lines: @@ -46,8 +45,11 @@ def __parse_coded_line(self, line): index = int(index) has_id = True + # characterictics for all characteristics + if index == 0: + pass # header - number of characteristics in file - if code[0:5] == "K0100": + elif code[0:5] == "K0100": print(f"Count of characteristics in DFQ file: {value}") # part information elif code[0:2] == "K1": @@ -115,7 +117,7 @@ def __parse_uncoded_measurements(self, line): elements = data.split("\x14") self.__characteristic = 0 - if len(elements) >= 2: + if len(elements) >= 2 and str(elements[1]).strip(): self.__characteristic = int(elements[1]) if attributed == 1 and len(elements) >= 4: self.__characteristic = int(elements[3]) @@ -149,9 +151,9 @@ def __extract_measurement_info(self, attributed, elements): if len(elements) >= 1 + offset: self.__value = float(elements[0 + offset]) - if len(elements) >= 2 + offset: + if len(elements) >= 2 + offset and str(elements[1 + offset]).strip(): self.__characteristic = int(elements[1 + offset]) - if len(elements) >= 3 + offset: + if len(elements) >= 3 + offset and str(elements[2 + offset]).strip(): self.__datetime = datetime.strptime( elements[2 + offset], "%d.%m.%Y/%H:%M:%S" )