read_excel

petrophys.io.read_excel

read_excel(
filepath,
depth_column='DEPTH',
depth_unit=None,
well_name='',
sheet_name=None,
skiprows=0,
null_values=None,
well_column=None,
**kwargs,
)[source]

Read a log table from an Excel workbook and return Well object.

The sheet is read as read_csv() reads a CSV file with the same table: one row per depth, a depth column and one column per curve.

Parameters:
  • filepath (str or Path) – Path to the workbook (.xlsx, .xlsm or .xls)

  • depth_column (str, optional) – Name of depth column (default: “DEPTH”); a header with a unit, DEPTH (m) or DEPTH [m], is found by its name

  • depth_unit ({"m", "ft"}) – Unit of the depth column. Required unless the depth column header gives it (DEPTH (m)); when both are given they must agree.

  • well_name (str, optional) – Name for the well (default: the well identifier column’s value, else the file name without its suffix)

  • sheet_name (str or int, optional) – Sheet name or position (0 is the first). Default: the only sheet, or the first sheet whose header row has the depth column.

  • skiprows (int, optional) – Number of rows to skip above the header row

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

  • well_column (str, optional) – Column identifying the well (default: the first of WELL, WELLNAME, WELL_NAME, UWI and API present). It is read as text, names the well and is not a curve; a UWI or API column also sets header.uwi or header.api.

  • **kwargs – Additional arguments passed to pd.read_excel

Returns:

Well object with loaded data. A column header NAME (unit) or NAME [unit] gives curve NAME with that unit.

Return type:

Well

Raises:
  • FileNotFoundError – If the workbook does not exist.

  • ValueError – If no sheet has the depth column, the depth column has no numeric value, two columns become the same curve name (they differ only in case or unit), the sheet holds several wells, or the depth header’s unit differs from depth_unit.

Examples

>>> from petrophys.io import read_excel
>>> well = read_excel("well_logs.xlsx", depth_unit="m")