When exporting to CSV, large strings are causing other cells to be rewritten. See the screenshot for the result of the export here.
For the code related to this issue, refer to this link. The question is how to prevent large string values in a cell from affecting other data in adjacent cells.
var newS = {
Name: "https://www.someweb.com/product/2019-new-shoulder-bags-leather-bucket-bag/452346283.html?d1_posid=6c776030d97bebe241c60070a53e7683&dspm=pcen.hp.relatedviewed.3.qJcEmZmc4A8ZV2ksdlct&resource_id=452346283#hp1507_reit-3-5|null:2001:r1045009996.json",
rating: "Google Inc",
rating: "Google Inc",
Price: "554.52"
}
stockData.push(newS);
}
function convertArrayOfObjectsToCSV(args) {
var result, ctr, keys, columnDelimiter, lineDelimiter, data;
data = args.data || null;
if (data == null || !data.length) {
return null;
}
columnDelimiter = args.columnDelimiter || ',';
lineDelimiter = args.lineDelimiter || '\n';
keys = Object.keys(data[0]);
result = '';
result += keys.join(columnDelimiter);
result += lineDelimiter;
data.forEach(function(item) {
ctr = 0;
keys.forEach(function(key) {
if (ctr > 0) result += columnDelimiter;
result += item[key];
ctr++;
});
result += lineDelimiter;
});
return result;
}