Re: xlrd and lxml.etree.parse() error

113 views
Skip to first unread message

John Machin

unread,
May 17, 2013, 8:29:56 PM5/17/13
to python-excel


On May 18, 1:26 am, doke...@gmail.com wrote:
> Hello,
>
> I am writing an service that use xlrd and my own excel library.

What is "my own excel library" intended to do?

>
> xlrd is to read and my own script is to write.
>
> my script used BeautifulSoup4 to parse. But I am changing it to lxml for
> speed.

Your own script is writing what? Parsing what?

>
> Unfortunately, I got an error "not well-formed (invalid token): line 1,
> column 31" when run "xlrd.open_workbook('excel')"

That looks like an error message from lxml. You are trying to open a
file whose name is "excel"? What type of file is it? xlsx? What
software created it?

Please show the full traceback and error message. Also state what
version of Python and what version of xlrd.

>
> I don't know exact cause but I found the error occured when
> etree.parse('xml file in excel') in my script.

What is "xml file in excel" ? Do you mean what you would get by Save
As "XML Spreadsheet 2003 (*.xml) ?

>
> So I have tried many ways and I found a solution.
>
> with open('xl/shardStringxml') as f:

What is "xl/shardStringxml" ?


>     _xml = f.read()
>     XML = etree.XML(_xml)
>
> In short, I guess that etree.parse() maybe crash with xlrd but etree.XML()
> is OK.

I wouldn't regard telling you that your xml input is not well-formed
as "crashing". I'd call it "expected behaviour". Please explain what
you mean by, and what is the relevance of, "with xlrd".

>
> Could you explain to me?

Not without a lot more information, as requested above.
Reply all
Reply to author
Forward
0 new messages