solutions-webappbuilder-widgets-dev/ImageDiscovery/lib/papa_parse.js
// The double for loop that iterates the data and writes out a CSV string including header row
The double for loop that iterates the data and writes out a CSV string including header row
The double for loop that iterates the data and writes out a CSV string including header row
function serialize(fields, data)
        {
            var csv = "";
            if (typeof fields === 'string')
                fields = JSON.parse(fields);
            if (typeof data === 'string')
                data = JSON.parse(data);
            var hasHeader = fields instanceof Array && fields.length > 0;
            var dataKeyedByField = !(data[0] instanceof Array);
            if (hasHeader)
            {
                for (var i = 0; i < fields.length; i++)
                {
                    if (i > 0)
                        csv += _delimiter;
                    csv += safe(fields[i], i);
                }
                if (data.length > 0)
                    csv += _newline;
            }
            for (var row = 0; row < data.length; row++)
            {
                var maxCol = hasHeader ? fields.length : data[row].length;
                for (var col = 0; col < maxCol; col++)
                {
                    if (col > 0)
                        csv += _delimiter;
                    var colIdx = hasHeader && dataKeyedByField ? fields[col] : col;
                    csv += safe(data[row][colIdx], col);
                }
                if (row < data.length - 1)
                    csv += _newline;
            }
            return csv;
        }
function serialize ( fields , data ) { var csv = "" ; if ( typeof fields === 'string' ) fields = JSON . parse ( fields ) ; if ( typeof data === 'string' ) data = JSON . parse ( data ) ; var hasHeader = fields instanceof Array && fields . length > 0 ; var dataKeyedByField = ! ( data [ 0 ] instanceof Array ) ; if ( hasHeader ) { for ( var i = 0 ; i < fields . length ; i ++ ) { if ( i > 0 ) csv += _delimiter ; csv += safe ( fields [ i ] , i ) ; } if ( data . length > 0 ) csv += _newline ; } for ( var row = 0 ; row < data . length ; row ++ ) { var maxCol = hasHeader ? fields . length : data [ row ] . length ; for ( var col = 0 ; col < maxCol ; col ++ ) { if ( col > 0 ) csv += _delimiter ; var colIdx = hasHeader && dataKeyedByField ? fields [ col ] : col ; csv += safe ( data [ row ] [ colIdx ] , col ) ; } if ( row < data . length - 1 ) csv += _newline ; } return csv ; }
The double for loop that iterates the data and writes out a CSV string including header row
The double for loop that iterates the data and writes out a CSV string including header row
// If there a header row, write it first // Then write out the data