I've been trying to look on the internet for a piece of code or a direction that could help me solve this issue.
Basically, I have a set of data over four columns where in the latest column a description is given on what the data is representing.
I am importing new data everyday where the description could be the same but a different set of data is given which are just numbers.
Now I would like my script to find the duplicates, take the data and add that to the original data and remove the duplicate.
So, I only want to accumulate column one and delete the rest of the data.
I'm aware of how to find duplicates, delete the entire set of data and push the new set of data without duplicates to the sheet.
However, I cannot find any possibility for this online. It is probably a possibility to get the values of a range in the var Newdata copy that to the row where the duplicate is found and then push that array in its entirety.
However, everything i've tried to incorporate that gives me multiple bugs and infinite calculation times.
I hope someone can help me with this.
function DuplicateRemoval(){
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();
var newData = new Array();
for(i in data){
var row = data[i];
var duplicate = false;
for(j in newData){
if(row.join() == newData[j].join()){
duplicate = true;
}
}
if(!duplicate){
newData.push(row);
}
}
sheet.clearContents();
sheet.getRange(1, 1, newData.length, newData[0].length).setValues(newData);
}