There are 3 duplicate articles from the same domain in Sheet1: https://docs.google.com/spreadsheets/d/1pExqHJQubnSPDKczkF9HMA2QN1cxTYmzyewQdugDRYs/edit#gid=0
Goal: I'd like to remove articles that have the same title AND domain.
Sheet DesiredResult has the desired result.
I'd like to modify this filter script to compare article title(column a) & domain(column C), if they are the same, then remove:
function removeDuplicates() {
const sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1');
const data = sheet.getDataRange().getValues();
var temp = {}; // Added
var newData = data.filter(function(e) { // Added
if (!temp[e[1]]) {
temp[e[1]] = e[1];
return true;
}
return false;
});
sheet.clearContents();
sheet.getRange(1, 1, newData.length, newData[0].length).setValues(newData);
}
Right now it just looks at the link if they're the same. It's not using an if statement so I'm not sure how to add a comparison for 2 columns. Any help is appreciated, thanks!
Update: I've tried looking at !temp[e[1]] to see if there are values to compare in an if statement but it shows as undefined so I'm stuck where to add the second column comparison in this section.
Reference: Previous question, asked to compare 1 column - Google Sheet Scripts: How to compare only one column to remove duplicates
temp[e[1]]- sojim2