loglevel=7
ignore_loglevel
panic=60
debug
acpi=off noapic nomodeset
// 1) Получить все данные из источника
const sourceSsId = "asdfg";
const sourceSheetName = "Sheet1";
const destinationSsId = "asdfg2";
const destinationSheetName = "Sheet2";
let [sourceHeaders, ...sourceData] = SpreadsheetApp.openById(sourceSsId).getSheetByName(sourceSheetName).getDataRange().getValues();
// 2) Убрать все строки (по какому-то ключевому столбцу) которые уже есть в приёмнике
const destinationSsId = "asdfg";
const destinationSheetName = "Sheet1";
let [destinationHeaders, ...destinationData] = SpreadsheetApp.openById(destinationSsId).getSheetByName(destinationSheetName).getDataRange().getValues();
const sourceKeyColumnId = 0; // Столбец A в источнике
const destinationKeyColumnId = 0; // Столбец A в приёмнике
let sourceKeys = sourceData.map(dataRow=>dataRow[sourceKeyColumnId]);
let filteredData = destinationData.filter(dataRow=>{
let destinationKey = dataRow[destinationKeyColumnId];
return !sourceKeys.includes(destinationKey);
});
// 3) Добавить дату копирования в каждую из оставшихся после фильтра строк
let now = new Date();
filteredData = filteredData.map(dataRow=>[...dataRow, now])
// 4) Добавить эти данные в приёмнике
let outSheet = SpreadsheetApp.openById(destinationSsId).getSheetByName(destinationSheetName);
if (filteredData.length){
outSheet.getRange(outSheet.getLastRow()+1, 1, filteredData.length, filteredData[0].length).setValues(filteredData);
};