Counts the number of instances of a specified pattern in a column and writes that value into a newly generated column. Source column is unchanged. |
countpattern col: myCol on: 'honda' |
Output: Generates a new column containing the number of instances of the string honda
that appear in each row of the column, myCol
.
countpattern col:column_ref [ignoreCase:true|false] [after:start_point | from: start_point] [before:end_point | to:end_point] [on:'exact_match'] |
Token | Required? | Data Type | Description |
---|---|---|---|
countpattern | Y | transform | Name of the transform |
col | Y | string | Source column name |
ignoreCase | N | boolean | If true , matching is case-insensitive. |
Matching parameters:
NOTE: At least one of the following parameters must be included to specify the pattern to count: |
Token | Required? | Data Type | Description |
---|---|---|---|
after | N | string | String literal or pattern that precedes the pattern to match |
before | N | string | String literal or pattern that appears after the pattern to match |
from | N | string | String literal or pattern that identifies the start of the pattern to match |
on | N | string | String literal or pattern that identifies the pattern to match. |
to | N | string | String literal or pattern that identifies the end of the pattern to match |
Identifies the column to which to apply the transform. You can specify only one column.
countpattern col: MyCol on: 'MyString' |
Output: Counts the number of instances of the value MyString
in the MyCol
column and writes this value to a new column.
Required? | Data Type |
---|---|
Yes | String (column name) |
countpattern col: MyCol after: 'entry:' |
Output: Counts 1
if there is anything that appears in the MyCol
column value after the string entry:
. If the value entry:
does not appear in the column, the output value is 0
.
Required? | Data Type |
---|---|
No | String (string literal or pattern) |
after
and from
parameters are very similar. from
includes the matching value as part of the extracted string.after
can be used with either to
, on
, or before
. See Pattern Clause Position Matchingcountpattern col: MyCol before: '|' |
Output:
1
if there is a value that appears before the pipe character (|
) in the MyCol
column, and no other pattern parameter is specified. If the before
value does not appear in the column, the output value is 0
.after
is specified, the total count of instances is written to the new column.Required? | Data Type |
---|---|
No | String or pattern |
before
and to
parameters are very similar. to
includes the matching value as part of the extracted string.before
can be used with either from,
on
, or after
. See Pattern Clause Position Matching .countpattern col: MyCol from: 'go:' |
Output:
1
if contents from MyCol
that occur from go:
, to the end of the cell when no other pattern parameter is specified. If go:
does not appear in the column, the output value is blank.to
is specified, the total count of instances is written to the new column.Required? | Data Type |
---|---|
No | String or pattern |
after
and from
parameters are very similar. from
includes the matching value as part of the extracted string.from
can be used with either to
or before
. See Pattern Clause Position Matching .countpattern col: MyCol on: `###ERROR` |
Tip: You can insert the Unicode equivalent character for this parameter value using a regular expression of the form |
Required? | Data Type |
---|---|
No | String (literal, regular expression, or |
countpattern col:MyCol from:'note:' to: `/` |
Output:
MyCol
column of all values that begin with note:
up to a backslash character.0
or 1
.Required? | Data Type |
---|---|
No | String or pattern |
before
and to
parameters are very similar. to
includes the matching value as part of the extracted string.to
can be used with either from
or after
. See Pattern Clause Position Matching.countpattern col: MyCol on: 'My String' ignoreCase: true |
Output: Counts the instances of the following values if they appear in the MyCol
column: My String
, my string
, My string
, etc.
Required? | Data Type |
---|---|
No | Boolean |