Function csv

  • Fetches the CSV file at the specified input URL and returns a promise of an array of objects representing the parsed rows. The values of the properties of the parsed row objects are represented as strings.

    If init is specified, it is passed along to the underlying call to fetch.

    The generic parameter describes the column names as a union of string literal types.

    Type Parameters

    • Columns extends string

    Parameters

    • url: string

      A valid URL string.

    • Optional init: RequestInit

      An optional request initialization object.

    Returns Promise<DSVRowArray<Columns>>

  • Fetches the CSV file at the specified input URL and returns a promise of an array of objects representing the parsed rows.

    The specified row conversion function is used to map and filter row objects to a more-specific representation; see dsv.csvParse for details.

    The first generic parameter describes the type of the object representation of a parsed row. The second generic parameter describes the column names as a union of string literal types.

    Type Parameters

    • ParsedRow extends object

    • Columns extends string = string

    Parameters

    • url: string

      A valid URL string.

    • 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.csvParse; 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 Promise<DSVParsedArray<ParsedRow>>

  • Fetches the CSV file at the specified input URL and returns a promise of an array of objects representing the parsed rows.

    The init object is passed along to the underlying call to fetch.

    The specified row conversion function is used to map and filter row objects to a more-specific representation; see dsv.csvParse for details.

    The first generic parameter describes the type of the object representation of a parsed row. The second generic parameter describes the column names as a union of string literal types.

    Type Parameters

    • ParsedRow extends object

    • Columns extends string = string

    Parameters

    • url: string

      A valid URL string.

    • init: RequestInit

      An request initialization object.

    • 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.csvParse; 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 Promise<DSVParsedArray<ParsedRow>>