Skip to content

Commit 06e4668

Browse files
authored
Merge pull request #10 from dopplershift/fix-strip-header
Update header stripping
2 parents 26bedb3 + 686a7a7 commit 06e4668

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

strip_header.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ def setup_arg_parser():
4949

5050
# Find WMO header and remove
5151
def remove_header(block):
52-
data = block[:64].decode('utf-8', 'ignore')
53-
match = re.search('\x01\r\r\n[\w\d\s]{4}\r\r\n\w{4}\d{2} \w{4} \d{6}[\s\w\d]*\r\r\n', data)
52+
data = block[:64]
53+
match = re.search(r'\x01\r\r\n[\w\d\s]{4}\r\r\n\w{4}\d{2} \w{4} \d{6}[\s\w\d\r]*\r\r\n',
54+
data.decode('utf-8', 'ignore'))
5455
if match:
5556
return block[match.end():]
57+
# WMO block regex didn't match, see if we can see magic bytes for HDF5/netCDF
58+
elif ind := data.find(b'\x89HDF'):
59+
return block[ind:]
5660
else:
5761
return block
5862

0 commit comments

Comments
 (0)