generateCSV (deprecated)
generateCSV
was deprecated in version 4.28.0 of the JourneyApps Container and replaced with CSV
.
Format
generateCSV(source, options);
Parameter
Details
source
One of:
Array
Matrix (array of arrays)
options
(Optional)
Object with the following properties:
heading
: Array of column headingsdelimiter
: Character to separate columns with.
Defaults to ,
Returns: the generated CSV as a string.
Examples
var mx = [['Cell Phone', 'Black'], ['Computer','Red']];
var csv_file.csv = generateCSV(mx, { heading: ['Type', 'Color'] } );
In this case, csv_file
is:
Type,Color
Cell Phone,Black
Computer,Red
Suppose we have an asset
data model object with (amongst others) name
and cost
as fields, and we want to generate CSV for all assets and their names and costs:
var allAssets = DB.asset.all().toArray();
var myMx = allAssets.map(function(asset) {
return [asset.name, asset.cost];
});
var csv = generateCSV(myMx, {heading: ['Name', 'Cost']});
Last updated