Created
September 30, 2013 01:30
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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