---
description: The extract compute splits one column's value on separator characters and replaces the column with a single extracted sub-part.
date_published: 2026-08-13
date_modified: 2026-08-13
canonical_url: https://metricshub.org/community-connectors/develop/computes/extract.html
---

# extract (Compute)

On this Page

- [When To Use](#when-to-use)
- [Syntax](#syntax)
- [Properties](#properties)
- [Table Transformation Example](#table-transformation-example)
- [Recommended Pattern](#recommended-pattern)
- [Common Mistakes](#common-mistakes)
- [Community Examples](#community-examples)

## When To Use

Use `extract` when a single column packs several pieces of information into one string — `Model|Size`, `2.5 GHz`, `Name,Instance` — and you only need one of them. The compute splits the column value into sub-columns using the `subSeparators` characters and replaces the column, in place, with the sub-column selected by `subColumn`. All other columns and all rows are untouched.

For extracting a fixed-position slice of a string, see `substring`; for extracting a `key="value"` property from a WBEM object path, see [extractPropertyFromWbemPath](extract-wbem-property.html).

## Syntax

```yaml
sources:
  diskInventory:
    type: commandLine
    commandLine: ${file::list-disks.sh}
    computes:
    # Column 5 contains "Model|Size"; keep only "Model"
    - type: extract
      column: 5
      subColumn: 1
      subSeparators: '|'
```

## Properties

| Property | Required | Default | Description |
| --- | --- | --- | --- |
| `type` | Yes | None | `extract`. |
| `column` | Yes | None | **1-based** index of the column to split. The extracted sub-part replaces this column's value in place. |
| `subColumn` | Yes | None | **1-based** index of the sub-part to keep after splitting. If the separator never occurs in the value, the whole value is sub-column 1. |
| `subSeparators` | Yes | None | One or more separator **characters**. Each character in this string is an individual separator (like `awk -F"[...]"`), not a multi-character delimiter. Consecutive separators delimit empty sub-columns, which still count. Quote values that are special in YAML, e.g. `'\|'`, `'"'`, `','`. |

If `column` points past the end of a row, or a value in that column is missing, the compute logs a warning and leaves the whole table unchanged.

## Table Transformation Example

With `column: 5`, `subColumn: 1`, `subSeparators: '|'`:

#### Input

| ID | Vendor | Serial | Status | Model \| Size |
| --- | --- | --- | --- | --- |
| disk0 | Seagate | ZC11ABC | ok | ST4000NM\|4000 |
| disk1 | WDC | WX21DEF | ok | WD40EFRX\|4000 |

#### Result

| ID | Vendor | Serial | Status | Model |
| --- | --- | --- | --- | --- |
| disk0 | Seagate | ZC11ABC | ok | ST4000NM |
| disk1 | WDC | WX21DEF | ok | WD40EFRX |

Serialized, `disk0;Seagate;ZC11ABC;ok;ST4000NM|4000` becomes `disk0;Seagate;ZC11ABC;ok;ST4000NM`.

## Recommended Pattern

- Chain two `extract` computes to unpack a two-in-one column: first `duplicateColumn`, then extract sub-column 1 from the original and sub-column 2 from the copy (see `IpmiTool`, which splits `Model|Size` this way).
- Quote `subSeparators` whenever the character is meaningful in YAML (`'|'`, `'"'`, `':'`, `' '`).
- Extract before numeric computes (`multiply`, `divide`): `2.5 GHz` must become `2.5` before you can do arithmetic on it.

## Common Mistakes

- Treating `subSeparators` as one multi-character delimiter: `subSeparators: ', '` splits on comma **and** on space independently.
- Writing the property name as `subSeparator` (singular) — the correct property is `subSeparators` and a misspelled property is rejected by the schema.
- Forgetting that empty sub-parts count: with `subSeparators: ':'`, the value `a::b` has sub-columns `a`, `` (empty) and `b`, so `subColumn: 3` yields `b`.
- Expecting the split parts to be appended as new columns; `extract` replaces the original column with the single selected sub-part.

## Community Examples

- [IpmiTool](https://github.com/metricshub/community-connectors/blob/main/src/main/connector/hardware/IpmiTool/IpmiTool.yaml)
- [Windows](https://github.com/metricshub/community-connectors/blob/main/src/main/connector/system/Windows/Windows.yaml)
- [WBEMGenDiskNT](https://github.com/metricshub/community-connectors/blob/main/src/main/connector/hardware/WBEMGenDiskNT/WBEMGenDiskNT.yaml)

From `IpmiTool` (column 5 contains `Model|Size`; duplicate the column, then keep the model from the original and the size from the copy):

```
  # Duplicate the "Model" column because it is in the form of Model|Speed
  # Memory module;DeviceID;Entity ID;Vendor;Model|Speed;Model|Speed;SerialNumber;StatusArray;StatusInformation;AdditionalInformation1;
- type: duplicateColumn
  column: 5
  # Now extract "Model" from "Model|Size"
  # Memory module;DeviceID;Entity ID;Vendor;Model;Model|Speed;SerialNumber;StatusArray;StatusInformation;AdditionalInformation1;
- type: extract
  column: 5
  subColumn: 1
  subSeparators: '|'
  # Now extract "Size" from "Model|Size"
  # Memory module;DeviceID;Entity ID;Vendor;Model;Speed;SerialNumber;StatusArray;StatusInformation;AdditionalInformation1;
- type: extract
  column: 6
  subColumn: 2
  subSeparators: '|'
```
