From d50d2a9653ffbaa6362c1b498051de94ad7b611b Mon Sep 17 00:00:00 2001 From: Kent Inverarity <> Date: Thu, 24 Jun 2021 17:59:01 +0930 Subject: [PATCH 1/2] Fix #473 - parse header lines with no period --- lasio/reader.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lasio/reader.py b/lasio/reader.py index d3a715d..00290b9 100644 --- a/lasio/reader.py +++ b/lasio/reader.py @@ -918,17 +918,32 @@ def configure_metadata_patterns(line, section_name): unit_re = r"(?P([0-9]+\s)?[^\s]*)" # Alternate regular expressions for special cases + name_missing_period_re = r"(?P[^:]*):" + value_missing_period_re = r"(?P.*)" value_without_colon_delimiter_re = r"(?P[^:]*)" value_with_time_colon_re = ( r"(?P.*?)(?:(?[^.].*[.])\." no_desc_re = "" + no_unit_re = "" # Configure special cases - # 1. missing colon delimiter and description field - # 2. double_dots '..' caused by mnemonic abbreviation (with period) + # 1. missing period (assume that only name and value are present) + # 2. missing colon delimiter and description field + # 3. double_dots '..' caused by mnemonic abbreviation (with period) # next to the dot delimiter. + if ":" in line: + if not "." in line[:line.find(":")]: + # If there is no period, then we assume that the colon exists and + # everything on the left is the name, and everything on the right + # is the value - therefore no unit or description field. + name_re = name_missing_period_re + value_re = value_missing_period_re + desc_re = no_desc_re + unit_re = no_unit_re + value_with_time_colon_re = value_missing_period_re + if not ":" in line: # If there isn't a colon delimiter then there isn't # a description field either. From 9c82fb112252211e553c9f140625de2585ae818d Mon Sep 17 00:00:00 2001 From: Kent Inverarity <> Date: Fri, 25 Jun 2021 10:19:54 +0930 Subject: [PATCH 2/2] Add tests for #473 --- tests/test_read_header_line.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_read_header_line.py b/tests/test_read_header_line.py index 9ce519f..c2bb479 100644 --- a/tests/test_read_header_line.py +++ b/tests/test_read_header_line.py @@ -83,3 +83,28 @@ def test_unit_with_space(): assert result["unit"] == "1000 lbf" assert result["value"] == "" assert result["descr"] == "(RT)" + + +def test_line_without_period(): + line = " DRILLED :12/11/2010" + result = read_header_line(line) + assert result["name"] == "DRILLED" + assert result["value"] == "12/11/2010" + +def test_line_without_period_with_space(): + line = " PERM DAT :1" + result = read_header_line(line) + assert result["name"] == "PERM DAT" + assert result["value"] == "1" + +def test_line_without_period_with_colon(): + line = " TIME :14:00:32" + result = read_header_line(line) + assert result["name"] == "TIME" + assert result["value"] == "14:00:32" + +def test_line_without_period_with_decimal_value(): + line = " HOLE DIA :85.7" + result = read_header_line(line) + assert result["name"] == "HOLE DIA" + assert result["value"] == "85.7"