Parse a CSV-encoded field into known columns. It can parse values of the form:
value 1, value 2, value 3
"value 1", "value 2", value 3
(Quoted values. Quotes are optional.)"value 1"; "value 2"; value 3
(Using ; as delimiter. Delimiter is configurable.)
Parameter | Type | Required | Default Value | Description |
---|---|---|---|---|
columns | string or array | required | Names of columns to extract from field. | |
delimiter | string | optional[a] | , | Delimiter character to split records by. |
excludeEmpty | boolean | optional[a] | false | If the value of a column is empty, exclude the field. |
field [b] | string | required | @rawstring | Field that holds the input in CSV form. |
trim | boolean | optional[a] | false | Allows to ignore whitespace before and after values. If the value is quoted, the quotes can start after the spaces. Useful for parsing data created by sources that do not adhere to the CSV standard. |
[a] Optional parameters use their default value unless explicitly set. |
parseCsv()
Syntax Examples
For a log line like this:
2017-02-22T13:14:01.917+0000 [main thread] INFO statsModule got result="117,success,27%,3.14"
Using parseCsv(result,
columns=[count, status, completion, precision,
sourcetask])
will add these fields:
count | 117 |
status | success |
completion | 27% |
precision | 3.14 |
sourcetask will not get assigned a value, as there were too few columns in the input for that.
Use the (unnamed) field
parameter to
specify which field should be CSV parsed. Specify
@rawstring to parse the rawstring.
parseCsv()
Examples
Click
next to an example below to get the full details.Parse String as CSV
Parse a CSV-encoded field into known columns using
parseCsv()
function
Parse String as CSV - Example 2
Parse a CSV-encoded field into known columns using
parseCsv()
function and trim parameter
defined