parsecsv

Parses the comma-separated values (CSV) string or tab-separated values (TSV) string.

Syntax

parsecsv [OPTIONS] [FIELD, ...]
Optional Parameters
field=TARGET_FIELD
Field to be parsed in the input data stream (default: line).
overlay=BOOL
Option to control data-overwrite (default: f).
  • t: Outputs both the parsed data and the original data.
  • f: Outputs the parsed data only.
strict=BOOL
Option to conform RFC 4180 (default: f).
  • t: Parses the CSV file by strictly applying the RFC 4180: https://tools.ietf.org/html/rfc4180. It is the same as when you open the CSV file with Excel. This option cannot be used when tab=t.
  • f: Flexibly parses the CSV file.
tab=BOOL
Option to use tab character as a separator (default: f).
  • t: Uses tab character as a separator. This is useful for processing tab-separated values (TSV) files.
  • f: Uses comma (,) as a separator.
FIELD, ...
Name for the parsed field, separated by a comma (,). This option SHOULD always be in the last position. If no field names provided, the names column0, column1, ..., colnumnN are used in order.

Usage

  1. Parse comma-separated text

    json "{line: '\"foo\",\"bar\"'}" | parsecsv
    
  2. Parse comma-separated text to give name1 and name2 field names in order from the front.

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