A library for Google Apps Script (GAS). SOUWA can sum string elements in an array at the high speed.
SOUWA means summing in Japanese. SOUWA is a library for GAS. This can sum the string array elements 380 times faster than the general method by new algorithm which is called the pyramid algorithm. This can be used for creating large CSV data at Google Apps Script.
You can see the detailed report of this library at here. If you are interested in this, I'm glad.
- Google account
-
Add the library to your GAS project. You can see how to add the library at here.
-
Put the script ID of the library to "Find a Library" at Resources > Libraries. The script ID is "1yI93fL6G-jJwdYLCXSnbOkluQntDWo6QLARB6dMqObcJd-BYBd6wyasz".
-
You can use this by following command.
var sum = SOUWA.souwa(Array, Delimiter, Endcode);
Array is 1 or 2 dimentions. e.g. Array = [a, b, c,,,,,] or Array = [[a, b, c], [d, e, f, g],,,,,]. Delimiter is ',' and ':' and etc. Endcode is '\n' and '\r\n' and etc.
A sample used at demo.
function main() {
var row = 10;
var ar = new Array(row);
for (var i=0; i<row; i++) {
ar[i] = [String(("00"+(i+1)).slice(-2)), 'a', 'b', 'c', 'd', 'e'];
}
var result = SOUWA.souwa(ar, ',', '\n');
Logger.log("result:\n" + result);
}
Theory of this algorithm is here.
I would like to thank Google and Google staff.