Function csvParseRows

  • Parses the specified string, which must be in the comma-separated values format, returning an array of arrays representing the parsed rows.

    Unlike csvParse, this method treats the header line as a standard row, and should be used whenever CSV content does not contain a header. Each row is represented as an array rather than an object. Rows may have variable length.

    If a row conversion function is not specified, field values are strings. For safety, there is no automatic conversion to numbers, dates, or other types. In some cases, JavaScript may coerce strings to numbers for you automatically (for example, using the + operator), but better is to specify a row conversion function.

    Equivalent to dsvFormat(",").parseRows.

    Parameters

    • csvString: string

      A string, which must be in the comma-separated values format.

    Returns string[][]

  • Parses the specified string, which must be in the comma-separated values format, returning an array of arrays representing the parsed rows.

    Unlike csvParse, this method treats the header line as a standard row, and should be used whenever CSV content does not contain a header. Each row is represented as an array rather than an object. Rows may have variable length.

    Equivalent to dsvFormat(",").parseRows.

    Type Parameters

    • ParsedRow extends object

    Parameters

    • csvString: string

      A string, which must be in the comma-separated values format.

    • row: ((rawRow, index) => ParsedRow)

      A row conversion function which is invoked for each row, being passed an array representing the current row (d), the index (i) starting at zero for the first row, and the array of column names. If the returned value is null or undefined, the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object. In effect, row is similar to applying a map and filter operator to the returned rows.

        • (rawRow, index): ParsedRow
        • Parameters

          • rawRow: string[]
          • index: number

          Returns ParsedRow

    Returns ParsedRow[]