Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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