function csv( data, fields ) {
	var line;
	var out;
	var f;
	var i;
	var j;
	var n;
	var m;

	out = '';
	n = fields.length;
	m = n - 1;
	line = '';
	for ( j = 0; j < n; j++ ) {
		line += '"' + fields[ j ] + '"';
		if ( j < m ) {
			line += ',';
		}
	}
	out += line + '\n';
	for ( i = 0; i < data.length; i++ ) {
		line = '';
		for ( j = 0; j < n; j++ ) {
			f = fields[ j ];
			line += '"' + data[ i ][ f ] + '"';
			if ( j < m ) {
				line += ',';
			}
		}
		out += line + '\n';
	}
	return out;
}
Returns data as lines of comma-separated values (CSV).

@private
@param {ObjectArray} data - data to print
@param {StringArray} fields - output fields
@returns {string} CSV output