Skip to content

Parsing of invalid time metadata #605

@ArnaudGillioz

Description

@ArnaudGillioz

I occasionally encounter LAS files with invalid time metadata, as below:

#----------------------------------------------------------------------
~Parameter Information Section
BHT         .     20 degC                 :BHT
CVL         .     5350 m/s                :CasingVelocity
FluidDen    .     1.0 g/ccm               :Drilling Fluid Density
FLVT        .     1500 m/s                :FluidVelocity
LMFI        .     0.6 G                   :MFieldIntensity
MUDD        .     1.0 g/ccm               :MudWeight
Run         .     3                       :Run Number
TIME        .     17:72:59                :Time

In this case, the TIME parameter is parsed by lasio as:
HeaderItem(mnemonic="TIME", unit="", value="17", descr="60:59 :")

I believe this comes from the following regex, which only accepts hours 0-23 and minutes 0-59:

lasio/lasio/reader.py

Lines 1007 to 1009 in aef25d5

value_with_time_colon_re = (
r"(?P<value>.*?)(?:(?<!( [0-2][0-3]| hh| HH)):(?!([0-5][0-9]|mm|MM)))"
)

I think it would be preferable to parse the description based on the last colon, and let the user handle invalid times themselves. Any thoughts on this?

I'm using lasio 0.32 with Python 3.13.9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions