I am trying to delete certain columns based on the criteria. Like in this sheet https://docs.google.com/spreadsheets/d/1-P_OkgLeWhWJrOHcmC2sjQVgAoasoRiJ31VnKooHer0/edit?usp=sharing
the columns that contains '_confidence' or '_estimatedconfidence' or '_estimatedconfidence accuracy' needs to be deleted. I am trying to use this code:
function deleteColumns() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var dataRange = sheet.getRange("A1:A20");
var data = sheet.getRange("A1:A20");
var values = data.getValues();
var numRows = values.length;
var numCols = values[0].length;
for (var col = numCols-1; col > 0; col--) {
for (var row = 0; row < numRows; row++) {
switch (values[row][col]) {
case "_confidence":
case "_estimatedconfidence":
case "_estimatedconfidence accuracy":
sheet.deleteColumn(col+1);
continue;
break;
}
}
}
}
I have modified this code from the original source. This script doesn't returns anything.
P.S. I have not included all the columns to the sheet above. There can be upto 100 columns for processing.