Skip to content

Instantly share code, notes, and snippets.

@daveaiello
Last active April 13, 2017 16:22
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 daveaiello/1f338fae359148d755d6a58dfb170258 to your computer and use it in GitHub Desktop.
Save daveaiello/1f338fae359148d755d6a58dfb170258 to your computer and use it in GitHub Desktop.
Grab business-related iOS contact info from the clipboard and creating a new contact (run on Pythonista)
import contacts
import clipboard
name = clipboard.get().split('|')
pers = contacts.Person()
pers.organization = bytes(name[0], encoding='UTF-8')
pers.address = [(contacts.WORK,
{contacts.STREET: name[1],
contacts.CITY: name[2],
contacts.STATE: name[3],
contacts.ZIP: name[4],
contacts.COUNTRY: name[5]})]
pers.phone = [(contacts.MAIN_PHONE, name[6])]
if len(name) == 8:
pers.url = [(contacts.WORK, name[7])]
contacts.add_person(pers)
contacts.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment