views:

240

answers:

1

How can I import data for example for the field A1? When I use etree.parse() I get an error, because I dont have a xml file.

+1  A: 

It's a zip file:

import zipfile
from lxml import etree

z = zipfile.ZipFile('mydocument.ods')

data = z.read('content.xml')
data = etree.XML(data)

etree.dump(data)
MattH
http://paste.pocoo.org/show/184294/ I get an error
kame
What I've posted works for me with a OpenOffice spreadsheet saved as "mydocument.ods" in the working directory.`etree.dump` just prints a pretty version of the xml to stdout, are you running this with stdout nobbled? I've just got it there to show you that that is the parsed document containing the structure where the value of `A1` is stored.
MattH
I dont know stdout :/
kame
`stdout` - `Standard Output` is where a program writes its output to. http://en.wikipedia.org/wiki/Standard_streams The error message you posted isn't enough for me to be sure what's going on, but it seems clear you're not running the example I've posted.
MattH