Skip to content

Instantly share code, notes, and snippets.

@monsieuroeuf
Last active December 25, 2015 05:59
Show Gist options
  • Save monsieuroeuf/6928340 to your computer and use it in GitHub Desktop.
Save monsieuroeuf/6928340 to your computer and use it in GitHub Desktop.
Parse vcard file[s] generated by Contacts.app on OS X, and spit out some csv values suitable for use with Campaign Monitor etc.
#!/usr/bin/env python
import vobject
import sys
for fname in sys.argv[1:]:
f = open(fname)
v = vobject.readComponents(f)
while True:
try:
for i in v:
print u"{}, {}".format(i.fn.value, i.email.value).encode('utf-8')
break
except Exception, e:
print u"got an error: {}".format(i.fn.value)
@monsieuroeuf
Copy link
Author

Requires vobject.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment