parsecsv
Parses a CSV string in a text field and extracts each column as a field.
Command properties
| Item | Description |
|---|---|
| Command type | Processing query |
| Required permission | None |
| License usage | N/A |
| Parallel execution | Supported |
| Distributed execution | Not 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 ascolumn0,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
-
Parsing a CSV string
json "{'line': '\"foo\",\"bar\"'}" | parsecsvParses the CSV string in the
linefield and creates thecolumn0andcolumn1fields. -
Parsing with specified field names
json "{'line': '\"foo\",\"bar\"'}" | parsecsv name, valueParses the CSV string and creates the
nameandvaluefields. -
Parsing a tab-delimited string
json "{'line': 'foo\tbar\tbaz'}" | parsecsv tab=t col1, col2, col3Parses using the tab character as the delimiter.