The same email address is in my list twice

A contact list contains what is obviously the same person more than once.

Why it happens

  • Exact string comparison is case-sensitive, and email addresses are routinely written in whatever case the person typed.
  • The specification is partly to blame for the confusion.
  • Display wrappers cause the rest.
  • The consequence is not just an untidy list.

What to do now

  1. Lowercase and trim before comparing anything.
  2. Strip display wrappers first, so that what you are comparing is the address rather than the presentation of it.
  3. Decide which record wins per field rather than picking a row.

Next time

An email field is stored lowercased, so the case a sender happened to type stops being a difference at all.

Start from the contact list template.

Related problems

Set your fields once

Every file after that is checked before anything lands.