parsecsv

Parses a CSV string in a text field and extracts each column as a field.

Command properties

ItemDescription
Command typeProcessing query
Required permissionNone
License usageN/A
Parallel executionSupported
Distributed executionNot supported

Syntax

parsecsv [field=FIELD] [overlay={t|f}] [tab={t|f}] [strict={t|f}] [FIELD [, FIELD ...]]

Options

field=FIELD
Name of the field to parse (default: line)
overlay={t|f}
When set to t, preserves the original record's fields and overlays the parsed fields onto them. When omitted, outputs only the parsed fields. (default: f)
tab={t|f}
When set to t, uses the tab character as the delimiter. When omitted, uses a comma (,) as the delimiter. (default: f)
strict={t|f}
When set to t, parses strictly according to RFC 4180. (default: f)

Target

FIELD
Field names corresponding to each column. Specify multiple names in order, separated by commas (,). When omitted, names are automatically assigned as column0, column1, and so on.

Error codes

No error codes.

Description

The parsecsv command parses the CSV string in the specified field and extracts each column value as a field. If field names are specified, the corresponding name is used for each column; otherwise, names are automatically assigned as column0, column1, and so on.

Examples

  1. Parsing a CSV string

    json "{'line': '\"foo\",\"bar\"'}" | parsecsv
    

    Parses the CSV string in the line field and creates the column0 and column1 fields.

  2. Parsing with specified field names

    json "{'line': '\"foo\",\"bar\"'}" | parsecsv name, value
    

    Parses the CSV string and creates the name and value fields.

  3. Parsing a tab-delimited string

    json "{'line': 'foo\tbar\tbaz'}" | parsecsv tab=t col1, col2, col3
    

    Parses using the tab character as the delimiter.