'Timed out script
I'm using the following code in order to avoid using an IMPORTRANGE() formula. The data I'm getting is over 50k rows so that's why I'm using App Script.
But now I'm getting the following error:
Exception: Service Spreadsheets timed out while accessing document with id
function Live_Data_importing() {
var raw_live = SpreadsheetApp.openByUrl("someURL").getSheetByName("Sheet1");
var selected_columns = raw_live.getRange("A:Q").getValues().map(([a,,,,e,f,g,,i,j,,l,,n,o,]) => [a,e,f,g,i,j,l,n,o] );
var FF_filtered = selected_columns.filter(row=>row[8]=="somedata");
var FF_Hourly_live_data = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("somesheet");
FF_Hourly_live_data.getRange(2, 1, FF_filtered.length, FF_filtered[0].length).setValues(FF_filtered);
}
How can I fix this error? I also made a copy of the file but script is still running the same error.
Solution 1:[1]
Tested this on smaller set of data
It works okay
function Live_Data_importing() {
const ss = SpreadsheetApp.getActive();
var raw_live = ss.getSheetByName("Sheet3");
var selected_columns = raw_live.getRange("A1:Q" + raw_live.getLastRow()).getValues().map(([a, , , , e, f, g, , i, j, , l, , n, o,]) => [a, e, f, g, i, j, l, n, o]);//fix this range
var FF_filtered = selected_columns.filter(row => row[8] == 0);//My data is all integers
var FF_Hourly_live_data = ss.getSheetByName("Sheet4");//output sheet
FF_Hourly_live_data.getRange(2, 1, FF_filtered.length, FF_filtered[0].length).setValues(FF_filtered);
}
Data:
| COL1 | COL2 | COL3 | COL4 | COL5 | COL6 | COL7 | COL8 | COL9 | COL10 | COL11 | COL12 | COL13 | COL14 | COL15 | COL16 | COL17 | COL18 | COL19 | COL20 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 18 | 13 | 0 | 7 | 5 | 11 | 15 | 2 | 1 | 17 | 0 | 8 | 11 | 18 | 0 | 16 | 1 | 8 |
| 0 | 16 | 16 | 9 | 5 | 0 | 16 | 8 | 14 | 0 | 7 | 4 | 3 | 15 | 8 | 19 | 18 | 4 | 18 | 10 |
| 9 | 14 | 7 | 16 | 17 | 13 | 17 | 4 | 8 | 6 | 19 | 18 | 9 | 18 | 12 | 1 | 8 | 19 | 12 | 10 |
| 13 | 17 | 4 | 2 | 10 | 3 | 7 | 16 | 14 | 13 | 1 | 5 | 16 | 12 | 2 | 3 | 14 | 3 | 0 | 9 |
| 4 | 17 | 14 | 5 | 9 | 13 | 18 | 0 | 4 | 1 | 14 | 1 | 12 | 7 | 10 | 1 | 15 | 4 | 14 | 5 |
| 1 | 17 | 13 | 17 | 3 | 1 | 17 | 8 | 19 | 7 | 14 | 18 | 2 | 17 | 1 | 16 | 2 | 19 | 13 | 15 |
| 7 | 4 | 9 | 0 | 11 | 14 | 11 | 7 | 12 | 14 | 3 | 19 | 14 | 13 | 18 | 12 | 16 | 19 | 19 | 6 |
| 7 | 6 | 10 | 5 | 15 | 8 | 0 | 8 | 2 | 16 | 4 | 14 | 18 | 14 | 2 | 16 | 16 | 5 | 15 | 16 |
| 4 | 5 | 9 | 6 | 6 | 2 | 1 | 15 | 14 | 8 | 19 | 8 | 4 | 10 | 12 | 12 | 4 | 6 | 10 | 12 |
| 11 | 15 | 3 | 4 | 1 | 3 | 17 | 19 | 10 | 4 | 11 | 2 | 10 | 16 | 12 | 1 | 6 | 3 | 0 | 3 |
| 11 | 0 | 14 | 8 | 13 | 13 | 4 | 2 | 16 | 18 | 10 | 14 | 5 | 3 | 7 | 4 | 7 | 9 | 5 | 15 |
| 0 | 6 | 5 | 1 | 2 | 18 | 1 | 1 | 11 | 13 | 7 | 13 | 5 | 15 | 5 | 13 | 17 | 18 | 14 | 19 |
| 0 | 17 | 10 | 6 | 10 | 16 | 16 | 0 | 18 | 19 | 12 | 8 | 15 | 1 | 11 | 4 | 19 | 4 | 17 | 14 |
| 4 | 14 | 14 | 6 | 16 | 8 | 15 | 4 | 5 | 2 | 4 | 5 | 14 | 14 | 16 | 9 | 0 | 16 | 0 | 4 |
| 8 | 3 | 8 | 5 | 12 | 15 | 5 | 19 | 14 | 0 | 1 | 6 | 12 | 2 | 19 | 10 | 10 | 19 | 13 | 19 |
| 0 | 5 | 14 | 7 | 2 | 17 | 3 | 10 | 2 | 14 | 2 | 5 | 0 | 18 | 5 | 1 | 13 | 13 | 3 | 13 |
| 10 | 18 | 18 | 4 | 18 | 11 | 0 | 7 | 13 | 9 | 18 | 13 | 9 | 2 | 0 | 16 | 15 | 3 | 9 | 14 |
| 12 | 15 | 15 | 7 | 16 | 13 | 14 | 1 | 4 | 12 | 18 | 9 | 6 | 14 | 18 | 11 | 16 | 2 | 18 | 15 |
| 15 | 0 | 2 | 4 | 6 | 16 | 5 | 18 | 2 | 6 | 14 | 18 | 11 | 1 | 9 | 15 | 13 | 8 | 8 | 19 |
| 11 | 19 | 14 | 0 | 7 | 15 | 1 | 10 | 8 | 9 | 14 | 14 | 15 | 3 | 11 | 13 | 4 | 10 | 5 | 16 |
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
