Function to_csv

  • Main method

    Converts Javascript array data to CSV string data.

    This is the module's main method. Almost all use of this module should be through this method.

    Basic usage

    The module is pre-loaded with sensible defaults; as a result, generally it's good enough to just call this with your data, like so:

    import { to_csv } from 'csv_by_rfc';

    const data = [ ['ace', 'deuce', 'tres'], [1, 2, 3] ],
    csv = to_csv(data);

    console.log(csv); // 'ace,deuce,tres\r\n1,2,3'

    Embedded wacky text

    Of course, much of the purpose of a module like this is to make sure that the gross bits have been properly handled:

    import { to_csv } from 'csv_by_rfc';

    const data = [ ['ace', 'deuce'], [1, 2], ['a"b', 'c\r\nd'] ];
    console.log( to_csv(data) ); // 'ace,deuce\r\n1,2\r\n"a""b","c\r\nd"'

    Configuration

    whargarbl todo

    Parameters

    • data: string[][]

      The CSV's dataset

    • __namedParameters: StringifyOptions = {}

    Returns string

    The dataset as a CSV string

Generated using TypeDoc