Skip to content

GAS library for summing string elements in an array at the high speed

License

Notifications You must be signed in to change notification settings

tanaikech/SOUWA_GAS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SOUWA

Code Climate Issue Count

A library for Google Apps Script (GAS). SOUWA can sum string elements in an array at the high speed.

Description

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.

Demo

Requirement

  • Google account

Usage

  • 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.

Sample script

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

Theory of this algorithm is here.

Acknowledgements

I would like to thank Google and Google staff.

Licence

MIT

Author

TANAIKE

About

GAS library for summing string elements in an array at the high speed

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published