Function arrTableToCsv

  • Converts a 2D array to a CSV string.

    Type Parameters

    • T

    Parameters

    • input: T[][]

      The input 2D array.

    • delimiter: string = ';'

      The delimiter to use for separating values in the CSV string.

    • replaceLinebreakWith: string = '|'

      The character used to replace line breaks in the CSV string. Defaults to '|'.

    Returns string

    The CSV string representation of the input array.

    Remarks

    This function is useful for exporting data to CSV format.

    Typeparam

    T - The type of the elements in the input array.

    Example

    const input = [
    ['Name', 'Age', 'Country'],
    ['John', '25', 'USA'],
    ['Alice', '30', 'Canada'],
    ['Bob', '35', 'UK'],
    ];
    arrTableToCsv(input);
    //=> "Name;Age;Country\nJohn;25;USA\nAlice;30;Canada\nBob;35;UK"

Generated using TypeDoc