In case anybody has a similar issue to mine, here's a link to a gist showing the completed script: add-contact.py.
Latest posts made by daveaiello
Add an address to a contact
I'm brand new to Pythonista, and a fairly new Workflow user.
I'm trying to create a contact by passing certain data elements on the clipboard from a running workflow. Someone on the Workflow subreddit said that running a Pythonista script was the best way to do it, and offered the following code in a gist:
import contacts import clipboard import webbrowser name = clipboard.get().split(',') pers = contacts.Person() pers.first_name = name pers.last_name = name contacts.add_person(pers) contacts.save() webbrowser.open('workflow://')
My use is focused on creating contacts that exclusively contain information about businesses. So what I want to do is create a Person() that contains:
- work address
My modified code begins as follows:
import contacts import clipboard import webbrowser name = clipboard.get().split('|') pers = contacts.Person() pers.organization = bytes(name, encoding='UTF-8')
But then I get hung up on how to create an address, because I don't understand how to create Person.address from just reading the docs and reading through this forum.
Thanks for any guidance you can provide.