Monday, June 16, 2014

Bulk Reading and Writing

var names = new Array();
#####################################################5000 records in under a second..#####################################################function bulkscan() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getActiveSheet();
var range = sh.getRange(2, 16, 5800, 1);
//row, column, numrows, numcol)
//Create an array and store all of the values in it
var names = range.getValues();

for (i=0; i < names.length; ++i)
{
//this represents the first ("0") line of a multidimensional array
if (names[i][0].toString().trim().toUpperCase() == "REPLACE")
{
Logger.log("The Row is " + (i+2));
Logger.log("The domain is " + sh.getRange((i+2), 9).getValue());
}
}
}

#####################################################A HORIZONAL ARRAY VS A VERTICAL ARRAY#####################################################IF you are scanning like 1 row ACROSS you need to do this...  
for (i=0; i < header[0].length; ++i)   
{    Logger.log(header[0][i].toString().trim().toUpperCase());    
//this represents the first ("0") line of a multidimensional array    
if (header[0][i].toString().trim().toUpperCase() == "DOMAIN")

HOWEVER, If you are scanning like a long column down you need to do this..  
for (i=0; i < names.length; ++i)   
{    //this represents the first ("0") line of a multidimensional array    
if (names[i][0].toString().trim().toUpperCase() == "REPLACE")    dafd

notice the difference in the usage of the [0][i] vs the [i][0]









No comments:

Post a Comment