[Vobject] how to parse each part (street, postal code, country etc...) of an addresses with vobject?

Frederic Vautard fred at tektosworld.com
Mon Jan 11 03:28:57 CST 2010


Hi,

I am using Vobject to parse vcards. I have an issue to access each part 
of an address:

Here is my Vcard:
*BEGIN:VCARD
VERSION:3.0
N:Gump;Forrest
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
TEL;TYPE=WORK,VOICE:(111) 555-1212
TEL;TYPE=HOME,VOICE:(404) 555-1212
ADR;TYPE=WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America
LABEL;TYPE=WORK:100 Waters Edge\nBaytown, LA 30314\nUnited States of America
ADR;TYPE=HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
LABEL;TYPE=HOME:42 Plantation St.\nBaytown, LA 30314\nUnited States of 
America
EMAIL;TYPE=PREF,INTERNET:forrestgump at example.com
REV:20080424T195243Z
END:VCARD

*I can access the first address by typing:
*>>> print vcard.adr_list[0]
<ADR{u'TYPE': [u'WORK']}100 Waters Edge
Baytown, LA 30314
United States of America>*

I can just get the value of this address from:
*>>> print vcard.adr_list[0].value
100 Waters Edge
Baytown, LA 30314
United States of America*

Or I can get the fields separated by a ";" by using:
*>>> print vcard.adr_list[0].serialize()
ADR;TYPE=WORK:;;100 Waters Edge;Baytown;LA**;**30314**;**United States 
of America*

However I have to parse this output to get each field. Is there already 
a way in Vobject to get each part of the address independently ? 
(street, region, postal code, country....) ?

Thank you for your help and Best Regards,

Fred.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.skyhouseconsulting.com/pipermail/vobject/attachments/20100111/c318984f/attachment.htm 


More information about the VObject mailing list