I was asked to take 2 lists of names and dedupe the newer list with the names in the older list, so we only had a list of new names in a specific period (no dates here to help out!). Turned out to be a lot simpler than I thought. At first I thought Excel spreadsheet as the data wasn’t in a database. I thought I could do some fancy filter action, but nope! That was harder than a diamond on a bouncer’s knuckle!
Solution
The solution was a real simple tiny bit of .NET code:
var likes = System.IO.File.ReadAllLines(@"D:\likes.txt");
var olds = System.IO.File.ReadAllLines(@"D:\lomb-likes.txt");
var duped = new List<string>();
Array.ForEach(likes, like =>
{
var found = false;
Array.ForEach(olds, old =>
{
if(old == like)
{
found = true;
}
});
if(!found)
{
duped.Add(like);
}
});
var result = duped.OrderBy(dupe => Guid.NewGuid()).ToList();
Simples! Now get on with your work and stop reading my blog!
3 Comments

