Function tsvParse

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

    Unlike tsvParseRows, this method requires that the first line of the TSV content contains a tab-separated list of column names; these column names become the attributes on the returned objects.

    The returned array also exposes a columns property containing the column names in input order (in contrast to Object.keys, whose iteration order is arbitrary).

    Equivalent to dsvFormat("\t").parse. Note: requires unsafe-eval content security policy.

    Type Parameters

    • Columns extends string

    Parameters

    • tsvString: string

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

    Returns DSVRowArray<Columns>

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

    Unlike tsvParseRows, this method requires that the first line of the TSV content contains a tab-separated list of column names; these column names become the attributes on the returned objects.

    The returned array also exposes a columns property containing the column names in input order (in contrast to Object.keys, whose iteration order is arbitrary).

    Equivalent to dsvFormat("\t").parse. Note: requires unsafe-eval content security policy.

    Type Parameters

    • ParsedRow extends object

    • Columns extends string

    Parameters

    • tsvString: string

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

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

      A row conversion function which is invoked for each row, being passed an object representing the current row (d), the index (i) starting at zero for the first non-header 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, columns): ParsedRow
        • Parameters

          • rawRow: DSVRowString<Columns>
          • index: number
          • columns: Columns[]

          Returns ParsedRow

    Returns DSVParsedArray<ParsedRow>