#!/usr/bin/env python2.7
import vobject
abfile='/foo/bar/directory/file.vcf'
def test_vobject_dot_readOne():
with open(abfile) as f:
vcard = vobject.readOne(f)
vcard = vobject.readOne(f)
test_vobject_dot_readOne()
The above code does not work but if we remove one of the two repeated statements it does. I would like to read vcards one by one. Is there a way to do this with vobject.readOne(f)? How can I read vcard n from the file?
The vcf file I'm using is taken from google contacts (exporting as vcard format). Here is the file contents that I have used in the test with only two vcards:
BEGIN:VCARD
VERSION:3.0
FN:Foo_bar1
N:;Foo_bar1;;;
EMAIL;TYPE=INTERNET:[email protected]
END:VCARD
BEGIN:VCARD
VERSION:3.0
FN:Foo_bar2
N:;Foo_bar2;;;
EMAIL;TYPE=INTERNET:[email protected]
END:VCARD
One can then use the Vcard readings to perform comparisons to avoid duplicates as shown in another question:
Well let's hope I understood correctly what you were trying to do.
Are you trying to do something like this?
Or if you have the information in a file:
You would probably use
.readOne()
with a calendar file (.ics) since it would be composed of a single root object like in this example:Or if it is in a file: