kinverarity1 / lasio

Python library for reading and writing well data using Log ASCII Standard (LAS) files
https://lasio.readthedocs.io/en/latest/
MIT License
344 stars 151 forks source link

Not very clear error message "ValueError: could not convert string to float: b'~Version'" #79

Closed VelizarVESSELINOV closed 4 years ago

VelizarVESSELINOV commented 9 years ago

Missing ~A section, it would be good to have more clear message if it is LAS 2.0, that ~A section is missing, the current error message is unclear. And maybe this is valid LAS 3.0 file to be checked with the spec for LAS 3.0.

lasio.las.LASDataError: Failed to read data:
ValueError: could not convert string to float: b'~Version'
~Version Information
 VERS.  3.0   : CWLS LOG ASCII STANDARD
 WRAP.  NO    : One line per depth step
 DLM .  SPACE : Delimiting character
~Well Information
#MNEM.UNIT               DATA               DESCRIPTION
#---- ----        -------------------      ----------------
 STRT .F                 1088.1737       : First Index Value
 STOP .F                 8211.6737       : Last Index Value
 STEP .F                    0.5000       : Step
 NULL .                  -999.2500       : Null Value
 COMP .                       : Company
 WELL .                  : Well
 FLD  .                      : Field
 LOC  .                           : Location
 SRVC .             : Service company
 DATE .                        : Service Date {DD/MM/YYYY}
 CTRY .                               : Country
 STAT .                      : State
 CNTY .                         : County
 API  .                 : API Number
 LATI .                                  : Latitude
 LONG .                                  : Longitude
 GDAT .                                  : Geodetic Datum
~Curve
#MNEM  .UNIT            LOG CODES          CURVE DESCRIPTION
#----   ----        -------------------    -----------------
 DEPT  .F                                : Depth {F}
 TENS  .LBF                              : Tension {F}
 COLLAR.                                 : CCL {F}
 GAMMA .                                 : GR {F}
 3'AMP .MV                               : 3 Foot Amplitude {F}
 3'TRA .µS                               : 3 Foot Floating Gate Transit Time {F}
~   DEPTH     TENSION        CCL       GR        3' AMP      TT
  1088.1737   339.4208     9.0000    35.2786     0.8635   776.7905
  1088.6737   339.4208     9.0000    35.2786     0.8635   776.7905
kinverarity1 commented 9 years ago

It could be tricky to read that in using the existing parser...

kinverarity1 commented 4 years ago

With recent changes, this type of file does not cause an error message, which is, roughly, about the best we can do for now for this type of file.

tests/examples/issue79.las

>>> las = lasio.read('tests/examples/issue79.las')
>>> sections = las.sections.keys()
>>> sections
dict_keys(['Version', 'Well', 'Curves', 'Parameter', 'Other', "   DEPTH     TENSION        CCL       GR        3' AMP      TT"])
>>> las.sections[list(sections)[-1]]
[HeaderItem(mnemonic="1088:1", unit="1737", value="339.4208     9.0000    35....), 
 HeaderItem(mnemonic="1088:2", unit="6737", value="339.4208     9.0000    35....)]