{"id":9881,"library":"lasio","title":"lasio: Read/Write Well Data from LAS Files","description":"The `lasio` library (version 0.32) provides robust tools for reading and writing well data from Log ASCII Standard (LAS) files, supporting both LAS 1.2 and 2.0 specifications. It is actively maintained with regular updates for bug fixes and feature enhancements, typically releasing new minor versions a few times a year.","status":"active","version":"0.32","language":"en","source_language":"en","source_url":"https://github.com/kinverarity1/lasio","tags":["LAS","well data","geoscience","oil & gas","data parsing"],"install":[{"cmd":"pip install lasio","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for numerical data handling.","package":"numpy"},{"reason":"Core dependency for data frame operations and internal data structures.","package":"pandas"}],"imports":[{"symbol":"lasio.read","correct":"import lasio\nl = lasio.read('my_file.las')"},{"symbol":"lasio.LASFile","correct":"import lasio\nl = lasio.LASFile()"}],"quickstart":{"code":"import lasio\nimport io\n\n# Simulate a LAS file content for demonstration\nlas_content = \"\"\"~VERSION\nVERS.      2.00:  LAS Version\nWRAP.      NO:   No line wrapping\n~WELL\nSTRT.M     10.00: START DEPTH\nSTOP.M     20.00: STOP DEPTH\nSTEP.M     0.50:  STEP\nNULL.      -999.25: NULL VALUE\nWELL.      EXAMPLE WELL: WELL\nCOMP.      EXAMPLE CO: COMPANY\n~CURVE\nDEPT.M     : Depth\nGR.API     : Gamma Ray\nNEUT.V/V   : Neutron\n~A  DEPT      GR      NEUT\n  10.000   100.0   0.300\n  10.500   105.0   0.310\n  11.000   110.0   0.320\n  11.500   112.0   0.315\n  12.000   115.0   0.325\n\"\"\"\n\n# Read the LAS file from a string (or from a path: lasio.read('path/to/file.las'))\nlas_file_obj = io.StringIO(las_content)\nl = lasio.read(las_file_obj)\n\n# Access well information\nprint(f\"Well Name: {l.well.WELL.value}\")\nprint(f\"Company: {l.well.COMP.value}\")\n\n# Access curve data\nprint(f\"Gamma Ray Curve (first 3 values): {l['GR'][:3].tolist()}\")\nprint(f\"Depth Curve (last 2 values): {l['DEPT'][-2:].tolist()}\")\n\n# Convert to Pandas DataFrame\ndf = l.df()\nprint(\"\\nDataFrame head:\")\nprint(df.head())","lang":"python","description":"This quickstart demonstrates how to read a LAS file (simulated from a string for simplicity) using `lasio.read()`, access well header information, retrieve curve data, and convert the data into a Pandas DataFrame."},"warnings":[{"fix":"Explicitly pass the correct encoding to `lasio.read()`. Common alternatives are `encoding='latin-1'` or `encoding='cp1252'` based on the file's origin.","message":"LAS files frequently use non-standard encodings (e.g., 'latin-1', 'cp1252') that can cause `UnicodeDecodeError` if not specified. The default encoding for `lasio.read` is 'utf-8'.","severity":"gotcha","affected_versions":"all"},{"fix":"Review the 0.20.0 release notes. Ensure you are accessing curve metadata via `l.curves[idx].mnemonic`, `l.curves[idx].unit`, `l.curves[idx].value` and data via `l[mnemonic]` for consistency. Avoid direct mutation of `l.curves` lists if you previously did so.","message":"Version 0.20.0 introduced a significant refactor in how curve definitions and curve data are handled, using more explicit `CurveItem` objects. Direct access patterns used in older versions might break.","severity":"breaking","affected_versions":"<0.20.0"},{"fix":"Filter or impute `numpy.nan` values in your analysis, for example: `data_clean = l['GR'][~numpy.isnan(l['GR'])]` to remove NaNs before processing.","message":"When working with `lasio` data, remember to account for the `NULL` value defined in the LAS file header. `lasio` converts this value to `numpy.nan` by default.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Specify the correct encoding when reading the file, e.g., `l = lasio.read('your_file.las', encoding='latin-1')`.","cause":"The LAS file uses an encoding other than the default 'utf-8', such as 'latin-1' or 'cp1252', which cannot be decoded by 'utf-8'.","error":"UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf1 in position ...: invalid start byte"},{"fix":"Access well attributes through the `l.well` object and its `Item` objects, e.g., `well_name = l.well.WELL.value` or `company = l.well['COMP'].value`.","cause":"Well information attributes (like WELL, COMP, DATE) are not directly accessible as properties of the `LASFile` object. They are stored within the `l.well` object.","error":"AttributeError: 'LASFile' object has no attribute 'well_name' (or similar for other direct well attributes)"},{"fix":"Inspect the `~CURVE` section of the LAS file to ensure all data columns are properly defined with a unique mnemonic. If the file is uneditable, you might need to manually clean the data or skip the problematic section.","cause":"The LAS file contains data columns that do not have corresponding mnemonic definitions in the `~CURVE` section, indicating a malformed file.","error":"ValueError: No curve mnemonic found for curve with index ..."}]}