read_csv

petrophys.io.read_csv

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

Read CSV file and return Well object.

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

  • 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

  • skiprows (int, optional) – Number of rows to skip at start

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

  • 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, so identifiers keep their leading zeros, 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_csv (e.g. sep=";", decimal="," or thousands=","). Without sep, a header line that a semicolon or a tab splits into more columns than a comma does gives the separator; without decimal and thousands, a semicolon- or tab-separated file whose first rows write numbers as 2000,5 and none as 2000.5 is read with decimal commas.

Returns:

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

Return type:

Well

Raises:

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

Examples

>>> from petrophys.io import read_csv
>>> well = read_csv("well_data.csv", depth_column="MD", depth_unit="m")