Last active
April 13, 2017 16:22
-
-
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)
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 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