Skip to content

Instantly share code, notes, and snippets.

@oostendo
Created September 30, 2013 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oostendo/6758300 to your computer and use it in GitHub Desktop.
Save oostendo/6758300 to your computer and use it in GitHub Desktop.
quick python script for converting massive gmail contacts to iphone-friendly address book requires vobject (sudo easy_install vobject). Note this failed on a few unicode contacts which I had to remove from the VCF file manually.
import vobject
vcfdata = open("Downloads/00001.vcf").read()
out = open("Downloads/scrubbed.vcf", 'w')
contacts = vobject.readComponents(vcfdata)
done = False
while not done:
try:
contact = contacts.next()
except:
done = True
if contact.contents.get('tel', False):
if contact.contents.get('photo', False):
contact.contents.pop('photo')
if contact.contents.get('fn', False):
out.write(contact.serialize())
out.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment