From 1ad79f65f7409cc64ffe0d9f8ac220bff06c3a35 Mon Sep 17 00:00:00 2001 From: Floris Lambrechts Date: Thu, 12 Jul 2018 10:11:33 +0200 Subject: [PATCH] Recover from a broken Cn (by Michael Fox, ported to Python 3) Commit fbab53aa19d1aea43ff3ab2ace15058945f2e49 from https://github.com/cmars/pystdf/pull/1 ported to Python 3. --- pystdf/IO.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pystdf/IO.py b/pystdf/IO.py index c084392..23f2df0 100644 --- a/pystdf/IO.py +++ b/pystdf/IO.py @@ -163,6 +163,13 @@ def parse_records(self, count=0): if len(fields) < len(recType.columnNames): fields += [None] * (len(recType.columnNames) - len(fields)) self.send((recType, fields)) + if header.len > 0: + print( + "Warning: Broken header. Unprocessed data left in record of type '%s'. Working around it." % recType.__class__.__name__, + file=sys.stderr, + ) + self.inp.read(header.len) + header.len = 0 else: self.inp.read(header.len) if count: