Hierarchy

  • CsvUtils

Properties

Properties

createDataRows: ((rows, columnNames) => Promise<DataRow[]>)

Type declaration

    • (rows, columnNames): Promise<DataRow[]>
    • A utility method to convert a two-dimensional array of data into an array of DataRow.

      This function returns a Promise that resolves to an array of DataRow.

      Parameters

      • rows: string[][]
      • columnNames: string[]

      Returns Promise<DataRow[]>

      Example

      import { CsvUtils } from '@tableau/taco-toolkit/handlers'

      const rows: string[][] = [
      ["User1", "user1@example.com", "(555)555-5555"],
      ["User2", "user2@example.com", "(123)456-7890"],
      ]

      const columnNames: string[] = ["Name", "Email", "Phone Number"]

      const result = await CsvUtils.createDataRows(rows, columnNames)

      // result: an array of DataRow
parse: ((rawData, options) => Promise<{
    headers: string[] | undefined;
    rows: string[][];
}>)

Type declaration

    • (rawData, options): Promise<{
          headers: string[] | undefined;
          rows: string[][];
      }>
    • A utility method to parse CSV data into a two-dimensional array. Input data could be ArrayBuffer or string.

      This function returns a Promise that resolves to an object with headers and rows properties.

      Parameters

      • rawData: string | ArrayBuffer
      • options: {
            hasHeader: boolean;
        }
        • hasHeader: boolean

      Returns Promise<{
          headers: string[] | undefined;
          rows: string[][];
      }>

      Example

      import { CsvUtils } from '@tableau/taco-toolkit/handlers'

      const rawData: string =
      "Name,Email,Phone Number\n" +
      "User1,user1@example.com,(555)555-5555\n" +
      "User2,user2@example.com,(123)456-7890"

      const { headers, rows } = await CsvUtils.parse(rawData, { hasHeader: true})

      // result: an object with headers and rows properties

Generated using TypeDoc