Skip to content
Permalink
Browse files

BUGFIX #51, ignores empty lines in corrupted files

Thanks to @atorr018 for reporting this bug.

Some corrupted files show empty lines which are now ignored, thus if the
rest of the file makes sense it is parsed as usual.
  • Loading branch information...
castelao committed Aug 22, 2019
1 parent 92fa2c8 commit 800ccb5a7e7b37a26c0fdb9079ce735713aab157
Showing with 10 additions and 1 deletion.
  1. +1 −0 AUTHORS.rst
  2. +2 −1 seabird/cnv.py
  3. +7 −0 tests/test_parse.py
@@ -20,3 +20,4 @@ Contributors
* Uday Bhaskar; Provided SK287_CTD05.cnv, data columns with headers.
Reported bad path on seabird_dir() for windows machines.
* Mathew Biddle; Reported bug #53 on skipping first line if without header.
* @atorr018; Reported bug #51 on failing to parse due to a empty lines.
@@ -50,7 +50,8 @@ def __init__(self, raw_text, defaults=None):

module_logger.debug('Initializing CNV class')

self.raw_text = raw_text
# Clean empty lines first
self.raw_text = re.sub('\n\s*(?=\n)', '', raw_text)
self.defaults = defaults
self.attrs = {}
# ----
@@ -57,3 +57,10 @@ def test_column_header():
profile = CNV(raw.replace(' Depth Press \n' ,''))
assert len(profile['DEPTH']) == 3
assert profile['DEPTH'][0] == 3.973


def test_empty_lines():
"""Ignore corrupted empty lines
"""
raw = "* Sea-Bird SBE 9 Data File:\n\n* System UpLoad Time = Aug 01 2011 11:34:32\n \n# nquan = 2\n# nvalues = 3\n# name 0 = depSM: Depth [salt water, m]\n# name 1 = prDM: Pressure, Digiquartz [db]\n# start_time = Aug 01 2011 11:34:32\n# bad_flag = -9.990e-29\n# datcnv_date = Aug 02 2011 04:16:47, 7.18c\n# file_type = ascii\n*END*\n Depth Press \n 3.973 3.995\n 4.079 4.102\n 3.902 3.924\n"
profile = CNV(raw)

0 comments on commit 800ccb5

Please sign in to comment.
You can’t perform that action at this time.