From 742f7410beda3bce2288d72e9886e093dd209233 Mon Sep 17 00:00:00 2001 From: Arnaud TRAVERT Date: Wed, 8 Jun 2022 12:31:22 +0200 Subject: [PATCH] FIX parse_data In some instances, multiple entries - in particular 'AB' seem to be present, onlky the the first one is valid. The supplementary instances are kept and added in the dict with a key ending by '_(1)', '_(2)', etc... --- brukeropusreader/opus_parser.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/brukeropusreader/opus_parser.py b/brukeropusreader/opus_parser.py index ce81644..8381310 100644 --- a/brukeropusreader/opus_parser.py +++ b/brukeropusreader/opus_parser.py @@ -61,5 +61,12 @@ def parse_data(data: bytes, blocks_meta: List[BlockMeta]) -> OpusData: except UnknownBlockType: continue parsed_data = parser(data, block_meta) + # in some instances, multiple entries - in particular 'AB' seem to be present + # they are added with a key ending by '_(1)', '_(2)', etc... + if name in opus_data.keys(): + i = 1 + while name + '_(' + str(i) + ')' in opus_data.keys(): + i += 1 + name = name + '_(' + str(i) + ')' opus_data[name] = parsed_data return opus_data