Checking GMail contacts for iPhone sync issues

Google sync allows you to push sync your Google contacts to your iPhone. There are some quite arbitrary restrictions on the type and quantity of phone numbers that can be synced, as described here. Running the following piece of python next to an exported google.csv will check for entries that will loose phone numbers: ``

#Check a google.csv contact dump for iphone sync issues.
import csv
import collections 

#This is the problem: iPhone (when synced via exchange?) only allows
#a limited number of phone numbers -- which must be of specific types.
# See
 'Home Fax':1, 
 "Work Fax":1

def limitViolations(limits,types):
 for (type,num) in types.iteritems():
  if num>limits.get(type,0):
   return '%d > %d entries of type %s'%(num,limits.get(type,0),type)
 return ''

reader = csv.DictReader(open('google.csv','rb'),quoting=csv.QUOTE_MINIMAL)
for row in reader:
 # First pass only: see how many phone columns are active
 if nPhone<0:
  while row.has_key('Phone %d - Type'%nPhone):
 # Use phonetypes to tally the types for the active row
 for kPhone in range(1,nPhone):
  #if a phone value is given for this index, tally the type
  if len(row['Phone %d - Value'%kPhone])>0:
   phonetypes[row['Phone %d - Type'%kPhone]]+=1
 if v:
  print('%25s: %s'%(row['Name'],v))