read_ascii

petrophys.io.read_ascii

read_ascii(
filepath,
depth_column='DEPTH',
depth_unit=None,
well_name='',
delimiter=None,
header_line=0,
skiprows=0,
null_values=None,
column_names=None,
units_line=None,
**kwargs,
)[source]

Read ASCII well log file and return Well object.

This function handles various ASCII formats including space-delimited, tab-delimited, and custom delimiters.

Parameters:
  • filepath (str or Path) – Path to ASCII file

  • depth_column (str, optional) – Name of depth column (default: “DEPTH”)

  • depth_unit ({"m", "ft"}) – Unit of the depth column. Required unless the units line (units_line) or the depth column header (DEPTH (m), DEPTH [m]) gives it; the units line takes precedence, and a header unit must agree with depth_unit.

  • well_name (str, optional) – Name for the well

  • delimiter (str, optional) – Column delimiter (default: auto-detect tab, semicolon, comma or whitespace from the first data row)

  • header_line (int, optional) – Line number containing column headers (0-indexed)

  • skiprows (int, optional) – Number of rows to skip before header

  • null_values (scalar or list, optional) – Further null values (e.g. -99999) besides -999, -999.25, -9999, -9999.25, “null” and “NaN”

  • column_names (list of str, optional) – Column names if not in file

  • units_line (int, optional) – Line number containing units. A header NAME (unit) or NAME [unit] gives curve NAME with that unit; a unit on the units line takes precedence.

  • **kwargs – Additional arguments passed to pd.read_csv (e.g. decimal="," or thousands=",")

Returns:

Well object with loaded data

Return type:

Well

Raises:

ValueError – If the depth column is missing or has no numeric value, or two columns differ only in case.