shubs
08/04/2020, 6:49 PMstalbert
08/04/2020, 6:50 PMshubs
08/04/2020, 6:50 PMstalbert
08/04/2020, 6:53 PMshubs
08/04/2020, 6:59 PMbattk
08/04/2020, 6:59 PMbattk
08/04/2020, 6:59 PMbattk
08/04/2020, 7:00 PMshubs
08/04/2020, 7:00 PMbattk
08/04/2020, 7:00 PMshubs
08/04/2020, 7:01 PM//Creating a string variable that will be used as CSV Content
var contents='';
for(var z =0; z<content.length;z++){
contents +=content[z].toString() + '\n';
}
log.debug('contents',contents);
var fileObj = file.create({
name: 'testsearchcsv.csv',
fileType: file.Type.CSV,
contents: contents,
description: 'This is description',
folder: '161852'
});
fileObj.save();
shubs
08/04/2020, 7:02 PMstalbert
08/04/2020, 7:03 PMshubs
08/04/2020, 7:04 PMstalbert
08/04/2020, 7:06 PMstalbert
08/04/2020, 7:07 PMshubs
08/04/2020, 7:11 PMbattk
08/04/2020, 7:18 PMbattk
08/04/2020, 7:19 PMbattk
08/04/2020, 7:19 PMshubs
08/04/2020, 7:20 PMshubs
08/04/2020, 7:20 PMbattk
08/04/2020, 7:20 PMstalbert
08/04/2020, 7:26 PMmichoel
08/05/2020, 4:23 AMvar row = ['ABC', 'DEF,HIJ', 'A field with "double quotes"'];
var csvLine = row.map(function(field) {
return '"' + field.toString().replace(/"/g, '""') + '"';
}).join();
The theory is just to escape every double quote with two double quotes, and then wrap every field in double quotes.