# filter-rows

## Description

<mark style="color:purple;">`filter-rows`</mark> *adaptor filters rows in a datatable based on a search criteria or regular expression*.

Provides two datatables as outputs, one containing values that match the search criteria and one containing values that do not match the search criteria.

## Inputs

**`data`**\
Type: `datatable`\
Required: Yes\
The datatable to be searched.

**`column name`**\
Type: `text`\
Required: Yes\
The name of column in the datatable to be searched.

**`filter type`**\
Type: `text`\
Required: No\
The type of filter applied.

**`filter value`**\
Type: `text`\
Required: No\
A text or a regular expression to be searched for within the datatable columns. For when a range is needed, please use this format: number,number

**`case sensitive`**\
Type: `boolean`\
Required: No\
When set to `True`, lowercase and uppercase letters are treated as different when comparing text values. When set to `False`, lowercase and uppercase letters are treated as equivalent. If unspecified, defaults to `False`

## Outputs

**`data`**\
Type: `datatable`\
A datatable with the rows that match the testing pattern.

**`complementary`**\
Type: `datatable`\
A datatable with the rows that do not match the testing pattern.

## Examples

### Example 1: Default behaviour.

#### Inputs:

`data:`

| id | code | name           |
| -- | ---- | -------------- |
| 1  | GB   | United Kingdom |
| 2  | TR   | Turkey         |
| 3  | US   | United States  |
| 4  | IND  | India          |

`column name:` name

`filter type:` includes

`filter value:` United

`case sensitive:` *null*

#### Outputs:

`data`:

| id | code | name           |
| -- | ---- | -------------- |
| 1  | GB   | United Kingdom |
| 3  | US   | United States  |

`complementary`:

| id | code | name   |
| -- | ---- | ------ |
| 2  | TR   | Turkey |
| 4  | IND  | India  |

-> Filtered rows in the datatable based on the filter value `United` applied on the column `name`.

### Example 2: Filter rows with case sensitive set to true.

#### Inputs:

`data:`

| id | code | name           |
| -- | ---- | -------------- |
| 1  | GB   | United Kingdom |
| 2  | TR   | Turkey         |
| 3  | US   | United States  |
| 4  | IND  | India          |

`column name:` name

`filter type:` includes

`filter value:` united

`case sensitive:` True

#### Outputs:

`data`: Empty Datatable

`complementary`:

| id | code | name           |
| -- | ---- | -------------- |
| 1  | GB   | United Kingdom |
| 2  | TR   | Turkey         |
| 3  | US   | United States  |
| 4  | IND  | India          |

-> Filtered rows in the datatable using the case sensitive filter value `united` applied on the column `name`. This returns an empty datatable due to the case sensitive value being set to `True`.

## Use Cases

* Select data from one country in a datatable containing data from multiple countries.
* Select all rows that have values in a selected column within a stated range.
* Select all samples that have a particular sequencing run name.
* Select all samples with a flagged value in a certain column.
