I followed Google's Interacting With Your Docs List tutorial on how to write a script on importing CSV files. After a lot of help I got it to work. However when I try to copy it, or modify it in any way, it times out with the error message:
Exceeded maximum execution time.
...and doesn't run. Why would this be happening?
This is the importFromCSV()
function from the tutorial:
function importFromCSV() {
var fileName = Browser.inputBox("Enter the name of the file in your Docs List to import (e.g. myFile.csv):");
var files = DocsList.getFiles();
var csvFile = "";
for (var i = 0; i < files.length; i++) {
if (files[i].getName() == fileName) {
csvFile = files[i].getContentAsString();
break;
}
}
var csvData = CSVToArray(csvFile, ",");
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
for (var i = 0; i < csvData.length; i++) {
sheet.getRange(i+1, 1, 1, csvData[i].length).setValues(new Array(csvData[i]));
}
}