From 65557cc0f7c23e7419ab2e9c39c0f162c5db8a58 Mon Sep 17 00:00:00 2001 From: Eric Engle Date: Tue, 11 Jun 2024 15:18:25 -0400 Subject: [PATCH] Update for _grib2io.py Added an else to the for loop on checking for "GRIB" to continue when "GRIB" is not found in that loop. This will allow for grib2io to silently ignore data that are not GRIB2 message. --- src/grib2io/_grib2io.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/grib2io/_grib2io.py b/src/grib2io/_grib2io.py index 85e6955..c15bade 100644 --- a/src/grib2io/_grib2io.py +++ b/src/grib2io/_grib2io.py @@ -237,6 +237,11 @@ def _build_index(self): if header.to_bytes(4, "big") == b"GRIB": pos = pos + test_offset break + else: + # NOTE: Coming here means that no "GRIB" message identifier + # was found in the previous 2048 bytes. So here we continue + # the while True loop. + continue # Read the rest of Section 0 using struct. _secpos[0] = self._filehandle.tell()-4