I have a set of areas where multiple tests were ran at different locations. If a test doesn't pass, locations are retested on a different date.
Currently, below function that was posted as a solution by #TheWizEd to my question (Google App Script - Summarizes Result from Multiple Rows and Columns with Same Area Name) is not looping for dates and recording in the output, how can I add a second loop to achieve that or if there is a better way?
function Summary() {
try {
let sheet = SpreadsheetApp.openById(SpreadsheetID).getSheetByName(SheetName03);
let sheet04 = SpreadsheetApp.openById(SpreadsheetID).getSheetByName(SheetName04);
let values = sheet.getDataRange().getValues();
values.shift(); // remove the headers
// get unique sites
let areas = values.map( row => row[0] );
areas = [...new Set(areas)]
// find results for each area
let results = areas.map( area => [area,"Pass"]);
values.forEach( row => { let index = areas.findIndex( area => area === row[0] );
let tests = row.slice(2);
if( tests.indexOf("Fail") >= 0 ) {
results[index][1] = "Fail";
return;
}
else if( tests.indexOf( "" ) >= 0 ) {
results[index][1] = "Data Missing";
return;
}
}
);
sheet04.getRange(2,1,results.length,results[0].length).setValues(results);
}
catch(err) {
console.log(err);
}
}
This is the format of the data:
Present Output:
Intended Output:
Modification points:
In your script, the 1st column of the source sheet is checked. In order to achieve your goal, I thought that 1st and 2nd columns are required to be checked.
About the output values in your script, only 2 elements are included in each array of results values. In order to achieve your goal, 3 elements are required to be included in each array.
When these points are reflected in your script, how about the following modification?
Modified script:
function Summary() {
const SheetName03 = "Sheet1"; // Please set the sheet name of source sheet.
const SheetName04 = "Sheet2"; // Please set the sheet name of destination sheet.
const SpreadsheetID = "###"; // Please set your Spreadsheet ID.
const ss = SpreadsheetApp.openById(SpreadsheetID);
const sheet = ss.getSheetByName(SheetName03);
const sheet04 = ss.getSheetByName(SheetName04);
const [, ...values] = sheet.getDataRange().getValues();
const obj = values.reduce((m, [a, b, c, ...d]) => {
const k = `${a}###${b.toISOString()}`;
return m.set(k, m.has(k) ? [...m.get(k), ...d] : d);
}, new Map());
const results = [...obj].map(([k, v]) => {
const [a, b] = k.split("###");
return [a, new Date(b), v.includes("Fail") ? "Fail" : [...new Set(v)][0] == "Pass" ? "Pass" : "Data Missing"]
});
sheet04.getRange(2, 1, results.length, results[0].length).setValues(results);
}
When this script is run, the columns "A" and "B" of the source sheet are checked, and an array for putting to the destination sheet is created and the array is put to the destination sheet.
Note:
In this modified script, it supposes that the values of column "B" of the source sheet are the date object. Please be careful about this.
In this modified script, your showing sample Spreadsheet is used. So, when you change the sheet or your actual sheet is different from your showing sheet, this script might not be able to be used. Please be careful about this.
References:
reduce()
map()
Related
I'm using Google Forms to collect a data. So, there was one question in the Google Form that I considered as a primary key when using the VLOOKUP function. However, there is a possibility that some data will collect zero (0) for the answer since they do not have an official ID number yet. I'm wondering if there is a way for me to automatically add or update a value when the value is zero (0). I'm thinking of using an temporary ID which letters and numbers. Ex: ID000001
I believe your goal is as follows.
You want to convert 0 to ID000001. And, when the multiple 0 values are existing, you want to convert to ID000001, ID000002,,,.
In this case, how about the following sample script?
Sample script:
function myFunction() {
const sheetName = "Sheet1"; // Please set the sheet name.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
const range = sheet.getRange("A2:A" + sheet.getLastRow());
let c = 1;
const values = range.getValues().map(([a]) => [a === 0 ? `ID${(c++).toString().padStart(6, '0')}` : a]);
range.setValues(values);
}
In this script, it supposes that the column of "STUDENT ID" is the column "A" because I cannot know the column information from your sample image.
References:
map()
padStart()
Added:
From your following additional question,
Wait. If I run again the script, the output is starting again with ID000001. Is there a way for me to just continue the number?
In this case, how about using PropertiesServices as follows?
Sample script:
function myFunction() {
const sheetName = "Sheet1"; // Please set the sheet name.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
const range = sheet.getRange("A2:A" + sheet.getLastRow());
const p = PropertiesService.getScriptProperties();
const count = p.getProperty("count");
let c = count ? Number(count) : 1; // If you want to set the initial count, please modify 1 to other.
const values = range.getValues().map(([a]) => [a === 0 ? `ID${(c++).toString().padStart(6, '0')}` : a]);
range.setValues(values);
p.setProperty("count", c);
}
// When you want to reset the count, please run this function.
function reset() {
PropertiesService.getScriptProperties().deleteProperty("count");
}
For example, when all ID###### values are updated every run, you can also use the following sample script.
function myFunction() {
const sheetName = "Sheet1"; // Please set the sheet name.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
const range = sheet.getRange("A2:A" + sheet.getLastRow());
range.createTextFinder("^ID[\\d]+$").matchEntireCell(true).useRegularExpression(true).replaceAllWith(0);
let c = 1;
const values = range.getValues().map(([a]) => [a === 0 ? `ID${(c++).toString().padStart(6, '0')}` : a]);
range.setValues(values);
}
I have two spreadsheets named as source_data and target_data. I am comparing them both with the following code, however I want this code to return the exact cell address where the changes have been made. Also what exact change is there, the previous value of that cell and new value of that cell. Both sheets have same range as I am already copying the data of source_data with another function to the target_data sheet.
function updateSheet() {
const actualSheet = SpreadsheetApp.openById("1dtyM-Q3ej4q3NORbPAgTNlymcdLlBCXd4wbNbMMc8fE");
const copiedSheet = SpreadsheetApp.openById("14xvI7fUVxsMNMfAPWP-WUcoX2bo35S93CylC6RnjP7k");
let sourceValues = actualSheet.getSheetByName("admanager").getRange("A:D").getValues().filter(String)
let targetSheet = copiedSheet.getSheetByName("admanager")
let targetRange = targetSheet.getRange("A:D");
let targetValues = targetRange.getValues().filter(String)
let diff = targetValues.showDif(sourceValues)
Logger.log(diff);
// targetRange.clearContent();
// targetValues = (diff && diff.length) ? targetValues.concat(diff) : targetValues;
// targetSheet.getRange(15, 5, targetValues.length, targetValues[0].length).setValues(targetValues)
}
Array.prototype.showDif = function (array) {
let that = this;
return array.filter(function (r) {
return !that.some(function (x) {
return r.join() === x.join();
})
})
}
This code is giving the output in an array which returns the whole row where there is a difference.
output >>
1:54:04 PM Info [[a, bcd, lorem ipsumdh dchdbcbdj. bhjdbc.], [b, language, Lorem ipsum hbfhbfhdv]]
Kindly let me know how can I modify this code in such a way that it returns the exact Cell location and its value instead of an array with the whole row?
I believe your goal as follows.
You want to check the difference between the sheet of "admanager" in "actualSheet" sheet and the sheet of "admanager" in "copiedSheet" sheet using Google Apps Script.
You want to return the differences as the coordinates and each value of "actualSheet" sheet and "copiedSheet" sheet.
In this case, how about the following modified script?
Modified script:
function updateSheet() {
const a1Notation = "'admanager'!A:D"; // Please set the range.
const sourceSpreadsheetId = "###"; // Please set the Spreadsheet ID.
const targetSpreadsheetId = "###"; // Please set the Spreadsheet ID.
const [sourceValues, targetValues] = [sourceSpreadsheetId, targetSpreadsheetId].map(id => SpreadsheetApp.openById(id).getRange(a1Notation).getDisplayValues());
const diff = sourceValues.reduce((ar, r, i) => {
r.forEach((c, j) => {
if (c != targetValues[i][j]) ar.push({row: i + 1, col: j + 1, sourceValue: c, targetValue: targetValues[i][j]});
});
return ar;
}, []);
console.log(diff);
}
In this sample script, the cell values of 2 Spreadsheets of sourceSpreadsheetId and targetSpreadsheetId are compared, and when the cell values are different, the cell coordinate and each value are returned.
Result:
When above script is run, the following result is obtained.
[
{ row: 1, col: 1, sourceValue: 'a1', targetValue: 'updated' },
,
,
,
]
References:
map()
reduce()
I'm looking to get some help with Google Docs and Scripts. I have a workflow list that shows names of employees assigned to a task. There is also another field that indicates employees off of the day. I would like a script that can be run that would strikethrough the names of the individuals identified as off for the day. There could be multiple individuals off, so it would need to include a series of cells to reference. Results to look something like this.
[Requested outcome1
The problem I am running into is I cannot successfully find any code for even a starting point. I have seen pieces here and there, but nothing that is complete enough for me to even determine a starting point. I'm reasonably technical, but am not familiar with script writing. I have been unable to find a decent writeup on something like this so am requesting assistance if possible. Thank you!
Here is the code attempted where I am getting illegal argument on Line 27 currently. I will have it linked to a button. The individual in charge of updating the sheet daily will make all the daily changes, then once done click to button to clear any strikethrough and initiate based on new names input, if there are any.
Sample sheet link here.
https://docs.google.com/spreadsheets/d/1chSTd7Zy1qqu32qu4spSJJanwTI1SnH6rJtoMxb7iEc/edit?usp=sharing
function myFunction()
{
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('B:B').activate();
spreadsheet.getActiveRangeList().setFontLine(null);
const sheetName = "Sheet1"; // Please set the sheet name.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
const range = sheet.getRange('B2:B')
const textsForStrikethrough = sheet.getRange("A15:A20").getValues().flat(); // Added
const modify = range.getValues().reduce((ar, e, r) => {
e.forEach((f, c) => {
textsForStrikethrough.forEach(g => {
const idx = f.indexOf(g);
if (idx > -1) ar.push({start: idx, end: idx + g.length, row: r, col: c});
});
});
return ar;
}, []);
const textStyle = SpreadsheetApp.newTextStyle().setStrikethrough(true).build();
const richTextValues = range.getRichTextValues();
modify.forEach(({start, end, row, col}) => richTextValues[row][col] = richTextValues[row][col].copy().setTextStyle(start, end, textStyle).build());
range.setRichTextValues(richTextValues);
}
I believe your goal as follows.
You want to reflect the strikethrough to the partial text in a cell using Google Apps Script as follows. (The sample image is from your question.)
In this case, I would like to propose to use RichTextValueBuilder. The sample script is as follows.
Sample script:
function myFunction() {
const textsForStrikethrough = ["John"]; // Please set the texts you want to reflect the strikethrough.
const sheetName = "Sheet1"; // Please set the sheet name.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
const range = sheet.getDataRange();
const modify = range.getValues().reduce((ar, e, r) => {
e.forEach((f, c) => {
textsForStrikethrough.forEach(g => {
const idx = f.indexOf(g);
if (idx > -1) ar.push({start: idx, end: idx + g.length, row: r, col: c});
});
});
return ar;
}, []);
const textStyle = SpreadsheetApp.newTextStyle().setStrikethrough(true).build();
const richTextValues = range.getRichTextValues();
modify.forEach(({start, end, row, col}) => richTextValues[row][col] = richTextValues[row][col].copy().setTextStyle(start, end, textStyle).build());
range.setRichTextValues(richTextValues);
}
Result:
When above script is run, the following results are obtained.
Input situation:
This is the sample input situation before the script is run.
Output situation 1:
In this case, const textsForStrikethrough = ["John"]; is used for the input situation.
Output situation 2:
In this case, const textsForStrikethrough = ["John", "Amy"]; is used for the input situation.
Note:
In this sample script, all values are retrieved from the sheet and search the texts and reflect the strikethrough. So when you want to use this script to the specific range, please modify const range = sheet.getDataRange(); for your situation.
For example, from your sample image, when you want to use this script to the column "B", please modify it to const range = sheet.getRange("B1:B" + sheet.getLastRow());.
References:
Class RichTextValue
Class RichTextValueBuilder
Added:
About your following 2nd question,
This is perfect! Only other request I have, is how would we modify it to where it is referencing a series of other cells to lookup the names? The list of names changes daily, so looking to have all inputs be able to update by a simple change of the names on the sheet rather than modifying the code. So say the names could be input in cell A10:A15. Pulling that list of names and updating the "textsForStrikethrough" logic.
in this case, I think that at first, how about retrieving the values of cells "A10:A15", and use them as textsForStrikethrough?
Sample script 2:
function myFunction2() {
// const textsForStrikethrough = ["John"]; // Please set the texts you want to reflect the strikethrough.
const sheetName = "Sheet1"; // Please set the sheet name.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
const range = sheet.getDataRange();
const textsForStrikethrough = sheet.getRange("A10:A15").getValues().flat(); // Added
const modify = range.getValues().reduce((ar, e, r) => {
e.forEach((f, c) => {
textsForStrikethrough.forEach(g => {
const idx = f.indexOf(g);
if (idx > -1) ar.push({start: idx, end: idx + g.length, row: r, col: c});
});
});
return ar;
}, []);
const textStyle = SpreadsheetApp.newTextStyle().setStrikethrough(true).build();
const richTextValues = range.getRichTextValues();
modify.forEach(({start, end, row, col}) => richTextValues[row][col] = richTextValues[row][col].copy().setTextStyle(start, end, textStyle).build());
range.setRichTextValues(richTextValues);
}
In this script, the values of cells "A10:A15" in the sheet of sheetName are used as textsForStrikethrough.
Note:
Unfortunately, I cannot understand about your actual situation. So when above script cannot be used for your actual situation, can you provide your sample Spreadsheet for replicating the issue? By this, I would like to confirm it.
I am trying to combine rows of data where they match in Col A & Col B only.
In the example 1 - you can see 2 rows of Guitar D in Aisle 7 - Then the expected result of combining the duplicates together.
So combine the Qty`s together and list the latest date.
I am sorry I have no code to offer as an example as i cannot find something similar.
I do appreciate any help.
I believe your goal and situation as follows.
You want to achieve the image in your question.
Also, in your actual situation, the cells "A2:D" are used as the source range.
When the same values of "SKU" are existing and the values of "LOCATION" are different, the rows are not merged. Only when both values of "SKU" and "LOCATION" are the same, the rows are merged.
Pattern 1:
In this pattern, as your sample image, it supposes that the rows in the source sheet are sorted with "SKU", "LOCATION" and "DATE".
Sample script:
In this sample, it supposes that the source values are put in the sheet name of source and the output values are put to the sheet name of destination. So please modify them for your actual situation.
function myFnunction() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
// 1. Retrieve values from the source sheet.
const srcSheet = ss.getSheetByName("source");
const srcValues = srcSheet.getRange("A2:D" + srcSheet.getLastRow()).getValues();
// 2. Create an array for putting to the destination sheet.
const dstValues = srcValues.reduce((o, r) => {
if (r[0] == o.temp[0] && r[1] == o.temp[1]) {
o.temp[2] += r[2];
o.temp[3] = r[3];
} else {
o.ar.push(o.temp.length == 0 ? r : o.temp);
o.temp = r;
}
return o;
}, {ar: [], temp: []});
// 3. Put the values to the destination sheet.
const dstSheet = ss.getSheetByName("destination");
dstSheet.getRange(dstSheet.getLastRow() + 1, 1, dstValues.ar.length, dstValues.ar[0].length).setValues(dstValues.ar);
}
Pattern 2:
In this pattern, as your sample image, it supposes that the rows in the source sheet are NOT sorted with "SKU", "LOCATION" and "DATE".
Sample script:
In this sample, it supposes that the source values are put in the sheet name of source and the output values are put to the sheet name of destination. So please modify them for your actual situation.
function myFnunction() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
// 1. Retrieve values from the source sheet.
const srcSheet = ss.getSheetByName("source");
const srcValues = srcSheet.getRange("A2:D" + srcSheet.getLastRow()).getValues();
// 2. Create an array for putting to the destination sheet.
const dstObj = srcValues.reduce((o, r) => Object.assign(o, {[`${r[0]}_${r[1]}`]: (o[`${r[0]}_${r[1]}`] ? [o[`${r[0]}_${r[1]}`][0], o[`${r[0]}_${r[1]}`][1], o[`${r[0]}_${r[1]}`][2] + r[2], (o[`${r[0]}_${r[1]}`][3].getTime() < r[3].getTime() ? r[3] : o[`${r[0]}_${r[1]}`][3])] : r)}), {});
const dstValues = Object.values(dstObj);
// 3. Put the values to the destination sheet.
const dstSheet = ss.getSheetByName("destination");
dstSheet.getRange(dstSheet.getLastRow() + 1, 1, dstValues.length, dstValues[0].length).setValues(dstValues);
}
References:
getValues()
reduce()
Conditional (ternary) operator
setValues(values)
I am trying to compile data from one sheet containing order information to another sheets cell based on each customers name. I'd like to take the title of the column as well as the count for the item(s) they have ordered. I tried to brute force it with a formula in Google Sheets but the formula messes up and stops giving the correct information so I figured using a scripts function would be better for what I am trying to do. I made a new sheet to test a script on but have little experience and can't seem to make any progress.
I'd like to get the title(top row) of each column and the count of the item(s) into the order column on sheet2 base on the matching names on both sheets. If anyone could help or provide some insight it would be greatly appreciated.
Here is the code I came up with:
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var orders = ss.getSheetByName("Sheet2");
var data = ss.getSheetByName("Sheet1");
var names = orders.getRange("Sheet2!A2:A5");
var name = names.getValues();
var startRow = 1
var endRow = ss.getLastRow()
var getRange = ss.getDataRange();
var getRow = getRange.getRow();
var title = data.getRange("Sheet1!B1:J1");
var item = title.getValues();
var itemCell = data.getRange("Sheet1!B2").getValue();
var orderCell = orders.getRange(2,2).getValue()
Logger.log(itemCell)
if(itemCell>=0){
orders.getRange(2,2).setValue("item1 x " +itemCell)
}
currently this only has the desired effect on one cell and does not complete the row and repeat on next column.
Here is how I adjusted the code to try and fit a larger data set:
function myFunction() {
const srcSheetName = "Test Data";
const dstSheetName = "Order Changes";
const ss = SpreadsheetApp.getActiveSpreadsheet();
// 1. Retrieve source values.
const srcSheet = ss.getSheetByName(srcSheetName);
//I changed values 1,1 to change the values that were retreived
const [[, ...header], ...srcValues] = srcSheet.getRange(1, 1,
srcSheet.getLastRow(), srcSheet.getLastColumn()).getValues();
// 2. Create an object using the source values.
const srcObj = srcValues.reduce((o, [a, ...v]) => {
const temp = v.reduce((s, r, i) => {
if (r.toString() != "") s += `${header[i]} ${r}`;
return s;
}, "");
return Object.assign(o, {[a]: temp || ""});
}, {});
// 3. Retrieve the header column of destination values.
const dstSheet = ss.getSheetByName(dstSheetName);
//I changed values 2 or 1 to adjust the destination of values
const dstRange = dstSheet.getRange(2, 1, dstSheet.getLastRow() - 1);
const dstValues = dstRange.getValues();
// 4. Create the output values using the header column and the object.
const putValues = dstValues.map(([a]) => [srcObj[a] || ""]);
// 5. Put the values.
dstRange.offset(0, 1).setValues(putValues);
}
after making the changes and running the code the values would either not appear or appear in the wrong column with incorrect data.
Goal of function Update:
Match names in Sheet2!A with names in Sheet1!F
If a match is found combine header and value of cells in Sheet1!N1:BQ.
This should be from the same row of the matched name in Sheet1!F (example:
John Smith lm14 1, lm25 2, lm36 1)
Place combined data into Sheet2!C
Repeat for every name in Sheet2!A
header and cell value should not be combined if value < 0
I hope this helps to clarify any misunderstanding.
Here is are better example images:
I believe your goal as follows.
In your goal, the upper image in your question is the output you expect, and the cells "B2" should be item1 1 item3 1 item6 2 item9 3 when the lower input situation is used.
You want to achieve this using Google Apps Script.
In order to achieve above, I would like to propose the following flow.
Retrieve source values.
Create an object using the source values.
Retrieve the header column of destination values.
Create the output values using the header column and the object.
Put the values.
Sample script:
Please copy and paste the following script to the script editor of the Spreadsheet and set the source sheet name and destination sheet name, and run myFunction.
function myFunction() {
const srcSheetName = "Sheet1";
const dstSheetName = "Sheet2";
const ss = SpreadsheetApp.getActiveSpreadsheet();
// 1. Retrieve source values.
const srcSheet = ss.getSheetByName(srcSheetName);
const [[, ...header], ...srcValues] = srcSheet.getRange(1, 1, srcSheet.getLastRow(), srcSheet.getLastColumn()).getValues();
// 2. Create an object using the source values.
const srcObj = srcValues.reduce((o, [a, ...v]) => {
const temp = v.reduce((s, r, i) => {
if (r.toString() != "") s += `${header[i]} ${r}`;
return s;
}, "");
return Object.assign(o, {[a]: temp || ""});
}, {});
// 3. Retrieve the header column of destination values.
const dstSheet = ss.getSheetByName(dstSheetName);
const dstRange = dstSheet.getRange(2, 1, dstSheet.getLastRow() - 1);
const dstValues = dstRange.getValues();
// 4. Create the output values using the header column and the object.
const putValues = dstValues.map(([a]) => [srcObj[a] || ""]);
// 5. Put the values.
dstRange.offset(0, 1).setValues(putValues);
}
References:
getValues()
setValues(values)
reduce()
map()
Added 1:
About your current issue, the reason of your issue is that the ranges of source and destination are the different from the sample image in your question. My suggested answer is for the sample images in your initial question. When you changed the structure of the Spreadsheet, it is required to modify my suggested script. But from I changed values 1,1 to change the values that were retrieved and I changed values 2 or 1 to adjust the destination of values, I couldn't understand about your modified script. So as the additional script, I would like to modify my suggested answer for your updated question.
From your updated question and replyings, I understood that the source range and destination range are "N1:BQ" and "A52:C79", respectively. From this, please modify above sample script as follows.
From:
const [[, ...header], ...srcValues] = srcSheet.getRange(1, 1, srcSheet.getLastRow(), srcSheet.getLastColumn()).getValues();
To:
const [[, ...header], ...srcValues] = srcSheet.getRange("N1:BQ" + srcSheet.getLastRow()).getValues();
and
From:
dstRange.offset(0, 1).setValues(putValues);
To:
dstRange.offset(0, 2).setValues(putValues);
Added 2:
About your current issue, the reason of your issue is that the ranges of source and destination are the different from your 1st updated question in your question. My suggested answer is for the sample images in your 1st updated question. When you changed the structure of the Spreadsheet, it is required to modify my suggested script.
From your 2nd updated question, I understood that the source range and destination range are "F1:BQ" (the column "F" is the title and the columns "N1:BQ" are the values.) and "A2:C", respectively. From this, please modify above sample script as follows.
function myFunction() {
const srcSheetName = "Sheet1";
const dstSheetName = "Sheet2";
const ss = SpreadsheetApp.getActiveSpreadsheet();
// 1. Retrieve source values.
const srcSheet = ss.getSheetByName(srcSheetName);
const [[,,,,,,,, ...header], ...srcValues] = srcSheet.getRange("F1:BQ" + srcSheet.getLastRow()).getValues();
// 2. Create an object using the source values.
const srcObj = srcValues.reduce((o, [a,,,,,,,, ...v]) => {
const temp = v.reduce((s, r, i) => {
if (r.toString() != "") s += `${header[i]} ${r}`;
return s;
}, "");
return Object.assign(o, {[a]: temp || ""});
}, {});
// 3. Retrieve the header column of destination values.
const dstSheet = ss.getSheetByName(dstSheetName);
const dstRange = dstSheet.getRange(2, 1, dstSheet.getLastRow() - 1);
const dstValues = dstRange.getValues();
// 4. Create the output values using the header column and the object.
const putValues = dstValues.map(([a]) => [srcObj[a] || ""]);
console.log(srcObj)
// 5. Put the values.
dstRange.offset(0, 2).setValues(putValues);
}