Poor Data Entry of Phone Numbers

How many of you out there have phone number fields without any validation or formatting? I did. Today, I wrote a script to go through a database of contacts and "clean up" phone numbers and fax numbers. The script works as follows:
  1. Run through a list of contacts
  2. Remove all non-numeric elements from the #
  3. If it starts with a 1, start the string from the 2nd character
  4. Shorten the string to 10 characters
  5. If there are not 10 character return an empty string
  6. Otherwise, return the phone number without any punctuation
  7. If the phone # is not the same as it was prior to being processed, show the difference on the screen for human analysis
Worked perfectly for this data set. For other datasets, one could parse out extensions and convert letters (for example 1-800-MATTRESS)
Bookmark and Share    
blog comments powered by Disqus

0 COMMENTS