[Vobject] About vobject's usage

Pablo Antonio pabloa at gmail.com
Tue Aug 15 17:33:48 CDT 2006


Hello,
	I'm a pretty new python programmer that is doing his first steps
with the language. My necessity to read vcards brought me to vobject.

So far, the only thing I need is, as I said, parse and read vcards. In
the future I may implement the writing too.

I'm using a .vcf file a friend of mine sent me. He uses OS X and this is
the file where his contacts are stored. After doing the OS X ->
GNU/Linux conversions (basically removing the CTRL-M and CTRL-@ from the
file) I tried to load it using vobject:

<code>
# Yes, I know I have a rather weird path to voject.
# It's just that the installer didn't place the library where
# it should, apparently. So I had to create an __init__.py file
# in ./vobject/ in order to make this work.
from vobject.src import vobject
f = file("contacts.vcf")
s = ""
for x in f:
	s += x
v = vobject.readOne(s)
</code>

And that last line gives me the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/pablo/programs/python/telpy/vobject/src/vobject/base.py",
line 931, in readOne
    return readComponents(stream, validate, transform, findBegin).next()
  File "/home/pablo/programs/python/telpy/vobject/src/vobject/base.py",
line 893, in readComponents
    for line, n in getLogicalLines(stream, False, findBegin):
  File "/home/pablo/programs/python/telpy/vobject/src/vobject/base.py",
line 729, in getLogicalLines
    raise ParseError, 'Could not find BEGIN when trying to determine encoding'
vobject.src.vobject.base.ParseError: 'Could not find BEGIN when trying
to determine encoding'

It's just a fresh file like the one anybody who has OS X could create.
What am I doing wrong? I would also like to ask for more examples if
possible. There's just one regarding vcards parsing, and reading the
epydoc documentation didn't help in my case (as I said, I'm a newbie).

Of course, if this is not the right library for me I'd also like to hear
that from you. And, if possible, it would be nice to see any other
project that uses vobject's capabilities to understand how the parsing
should be done.

Thanks in advance.

-- 
Pablo Antonio (AKA crazy2k)
http://www.pablo-a.com.ar/



More information about the VObject mailing list