[Vobject] how to parse address in VCARDs

Jeffrey Harris jeffrey at skyhouseconsulting.com
Tue Jan 12 11:14:22 CST 2010


Hi Frederic,

You almost had it:

>>> print vcard.adr_list[0].value
100 Waters Edge
Baytown, LA 30314
United States of America

Rather than printing, just look at the repr() of the Address value,

>>> address = vcard.adr.value
>>> address
<Address: 100 Waters Edge\nBaytown, LA 30314\nUnited States of America>

This is a vobject.vcard.Address, so you can access its constituent fields by name:

>>> address.box, address.extended, address.street
('', '', u'100 Waters Edge')
>>> address.city, address.region, address.code, address.country
(u'Baytown', u'LA', u'30314', u'United States of America')

For more discussion of issues people have had with this, see this thread:

http://markmail.org/message/cqpfn52wc6jbmv2z

Sincerely,
Jeffrey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.skyhouseconsulting.com/pipermail/vobject/attachments/20100112/5987ab49/attachment.htm 


More information about the VObject mailing list