Checks a source sheet hourly and appends any rows it has not copied yet into a second sheet. One-way only - nothing is overwritten.
Uses
Google Sheets
Copy new rows to a second spreadsheet
sourceSpreadsheetLink to blank.Set sourceSpreadsheetLink to blank.sourceTabName to blank.Set sourceTabName to blank.destinationSpreadsheetLink to blank.Set destinationSpreadsheetLink to blank.destinationTabName to blank.Set destinationTabName to blank.keyColumnNumber to 1.Set keyColumnNumber to 1.maxNewRowsPerRun to 200.Set maxNewRowsPerRun to 200.sourceSpreadsheetLink split by /spreadsheets/d/ split by / and save it as sourceFileId.Get the first item of the last item of sourceSpreadsheetLink split by /spreadsheets/d/ split by / and save it as sourceFileId.destinationSpreadsheetLink split by /spreadsheets/d/ split by / and save it as destinationFileId.Get the first item of the last item of destinationSpreadsheetLink split by /spreadsheets/d/ split by / and save it as destinationFileId.sourceFileId is destinationFileId and sourceTabName is destinationTabNameIf sourceFileId is destinationFileId and sourceTabName is destinationTabNameYes
No
No steps
keyColumnNumber of sourceTabName in sourceSpreadsheetLink. Save it as sourceKeyColumn.Read column keyColumnNumber of sourceTabName in sourceSpreadsheetLink. Save it as sourceKeyColumn.sourceKeys to sourceKeyColumn.values.Set sourceKeys to sourceKeyColumn.values.keyColumnNumber of destinationTabName in destinationSpreadsheetLink. Save it as destinationKeyColumn.Read column keyColumnNumber of destinationTabName in destinationSpreadsheetLink. Save it as destinationKeyColumn.copiedKeys to destinationKeyColumn.values.Set copiedKeys to destinationKeyColumn.values.sourceKeys is emptyIf sourceKeys is emptyYes
No
No steps
copiedKeys is emptyIf copiedKeys is emptyYes
sourceTabName in sourceSpreadsheetLink. Save it as sourceHeaderRow.Read row 1 of sourceTabName in sourceSpreadsheetLink. Save it as sourceHeaderRow.headerValues to sourceHeaderRow.values.Set headerValues to sourceHeaderRow.values.headerValues isn't emptyIf headerValues isn't emptyYes
destinationTabName in destinationSpreadsheetLink.Add a row to destinationTabName in destinationSpreadsheetLink.No
No steps
No
No steps
copiedCount to 0.Set copiedCount to 0.blankKeyCount to 0.Set blankKeyCount to 0.failedCount to 0.Set failedCount to 0.rowNumber to 0.Set rowNumber to 0.sourceKey in sourceKeys:For each sourceKey in sourceKeys:rowNumber.Add 1 to rowNumber.rowNumber is 1If rowNumber is 1Yes
No
No steps
copiedCount is greater than or equal to maxNewRowsPerRunIf copiedCount is greater than or equal to maxNewRowsPerRunYes
No
No steps
rowErrorIf a step below fails, save the error as rowErrorTry
sourceKey and save it as rowKey.Trim sourceKey and save it as rowKey.rowKey is emptyIf rowKey is emptyYes
blankKeyCount.Add 1 to blankKeyCount.Else if @copiedKeys doesn't contain @rowKey
rowNumber of sourceTabName in sourceSpreadsheetLink. Save it as sourceRow.Read row rowNumber of sourceTabName in sourceSpreadsheetLink. Save it as sourceRow.rowValues to sourceRow.values.Set rowValues to sourceRow.values.rowValues isn't emptyIf rowValues isn't emptyYes
destinationTabName in destinationSpreadsheetLink.Add a row to destinationTabName in destinationSpreadsheetLink.rowKey to the end of copiedKeys and save it as copiedKeys.Add rowKey to the end of copiedKeys and save it as copiedKeys.copiedCount.Add 1 to copiedCount.No
No steps
Otherwise
No steps
On error
failedCount.Add 1 to failedCount.rowNumber of the source tab: rowError.message.Show in the output: Could not copy row rowNumber of the source tab: rowError.message.runSummary to Copied copiedCount new row(s) into '@destinationTabName'.Set runSummary to Copied copiedCount new row(s) into '@destinationTabName'.blankKeyCount is greater than 0If blankKeyCount is greater than 0Yes
runSummary to runSummary blankKeyCount row(s) had nothing in the key column and were left alone.Change runSummary to runSummary blankKeyCount row(s) had nothing in the key column and were left alone.No
No steps
failedCount is greater than 0If failedCount is greater than 0Yes
runSummary to runSummary failedCount row(s) could not be copied and will be tried again next run.Change runSummary to runSummary failedCount row(s) could not be copied and will be tried again next run.No
No steps
copiedCount is greater than or equal to maxNewRowsPerRunIf copiedCount is greater than or equal to maxNewRowsPerRunYes
runSummary to runSummary This run stopped at its limit of maxNewRowsPerRun rows; the next run carries on from there.Change runSummary to runSummary This run stopped at its limit of maxNewRowsPerRun rows; the next run carries on from there.No
No steps
runSummary.Show in the output: runSummary.