SOUWA_GAS
GAS library for summing string elements in an array at the high speed
AI Summary
SOUWA
A Google Apps Script library that rapidly concatenates string elements in arrays to create CSV or other text data.
Target Users
Intermediate to advanced GAS developers who need to shorten execution time when generating large CSV or text data.
Problems Solved
Ordinary string concatenation becomes slow with large arrays, risking script time-outs or quota overruns.
Tags
Main Features
Up to 380× faster concatenation
Uses a pyramid algorithm to concatenate 1-D or 2-D arrays up to 380 times faster than typical loop or join methods.
One-liner CSV generation
Create CSV strings in a single call, specifying delimiter and line-ending via SOUWA.souwa(Array, Delimiter, Endcode).
Supports 1-D and 2-D arrays
Handles both [a,b,c] and [[a,b],[c,d]] structures, fitting spreadsheet data exports.
Save execution time and GAS quotas
Acceleration reduces the chance of hitting the 6-minute limit or daily quotas, enabling larger datasets.
Usage Examples
Convert an array to a CSV string at high speed
// After adding the library to your GAS project, run the function below
function createCsv() {
// Build dummy data (10 rows × 6 columns)
const rows = 10;
const data = Array.from({ length: rows }, (_, i) => [
String((`00${i + 1}`).slice(-2)), // 01,02,...
'a', 'b', 'c', 'd', 'e'
]);
// Generate CSV quickly with SOUWA
// arg1: array, arg2: delimiter, arg3: line ending
const csv = SOUWA.souwa(data, ',', '
');
Logger.log(csv); // Output the generated CSV to the log
}
Paste the code into the Apps Script editor, add the library ID1yI93fL6G-jJwdYLCXSnbOkluQntDWo6QLARB6dMqObcJd-BYBd6wyasz
, and the csv
variable will contain a rapidly generated CSV string.