const arrayToCSV = (arr, delimiter = ',') => arr .map(v => v.map(x => (isNaN(x) ? `"${x.replace(/"/g, '""')}"` : x)).join(delimiter)) .join('\n');