简体   繁体   English

pyExcelerator在读取某些文件时遇到问题

[英]pyExcelerator has problems reading some files

I've got a problem using pyExcelerator when reading some xls-files. 读取一些xls文件时,使用pyExcelerator出现问题。

There're some python scripts i wrote, that use this library to parse XLS-files and populate database with info. 我写了一些python脚本,它们使用该库来解析XLS文件并使用信息填充数据库。

The templates for the files these scripts parse may vary and i sometimes reconfigure the script to handle them. 这些脚本解析的文件模板可能会有所不同,有时我会重新配置脚本以处理它们。 With the one of the templates i ran into problem: pyExcelerator just raises an exception: 使用其中一个模板,我遇到了问题:pyExcelerator引发了一个异常:

Traceback (most recent call last):
 File "/home/* * */parsexls.py",
line 64, in handle_label
   parser.parse()
 File "/home/* * */parsers.py", line 335, in parse
   self.contents = pyExcelerator.parse_xls(self.file_record.file,
self.encoding)
 File "/usr/local/lib/python2.6/dist-packages/pyExcelerator/ImportXLS.py",
line 327, in parse_xls
   ole_streams = CompoundDoc.Reader(filename).STREAMS
 File "/usr/local/lib/python2.6/dist-packages/pyExcelerator/CompoundDoc.py",
line 67, in __init__
   self.__build_short_sectors_data()
 File "/usr/local/lib/python2.6/dist-packages/pyExcelerator/CompoundDoc.py",
line 256, in __build_short_sectors_data
   dentry_start_sid, stream_size) = self.dir_entry_list[0]
IndexError: list index out of range

Some of the problem XLS-files contained empty sheets and removing of these sheets helped, but many of the files can't be handled even without empty sheets. XLS文件中的某些问题包含空白表,删除这些表很有帮助,但是即使没有空白表也无法处理许多文件。 There's nothing extraordinary in these files and they contain no formulas or pictures - just strings, numbers and dates. 这些文件中没有什么特别的东西,它们不包含公式或图片-只是字符串,数字和日期。

As i can see, the pyExcelerator is abandoned by it's author :( 如我所见,pyExcelerator被它的作者抛弃了:(

Any suggestions on fixing this issue are much appreciated. 任何有关解决此问题的建议都将受到赞赏。

I'm the author of xlrd. 我是xlrd的作者。 It r ea d s XLS files and is not a fork of anything. [R EA d小号XLS文件,而不是任何东西叉子。 I maintain a package called xlwt which w ri t es XLS files and is a fork of pyExcelerator. 我保持了一个名为xlwt包,其中,W牛逼 ES XLS文件,是pyExcelerator的一个分支。 The parse_xls functionality in pyExcelerator was deprecated to the point of removal from xlwt. pyExcelerator中的parse_xls功能已过时,已从xlwt中删除。 Use xlrd instead. 请改用xlrd。

Given the traceback that you reproduced, it looks like the file may be corrupted. 给定您复制的回溯,似乎文件可能已损坏。 What it is doing there happens well before the sheet data is parsed. 在解析工作表数据之前,它所做的工作非常好。 What software produces these files? 哪些软件生成这些文件? Can you open them with Excel or OpenOffice.org's Calc or Gnumeric? 您可以使用Excel或OpenOffice.org的Calc或Gnumeric打开它们吗? xlrd may give you a more meaningful error message. xlrd可能会给您更有意义的错误消息。 You may like to send me (insert_punctuation('sjmachin', 'lexicon', 'net')) copies of your failing file(s); 您可能希望将失败的文件的副本发送给我(insert_punctuation('sjmachin','lexicon','net')); please include some with and some without empty sheets. 请包括一些有无空纸的纸张。 By the way, what are you using to remove empty sheets? 顺便说一句,您正在使用什么来删除空纸? What error message do you get from pyExcelerator when processing files with empty sheets? 处理带有空工作表的文件时,您从pyExcelerator收到什么错误消息?

You might wish to give xlrd a try... it started (I believe) as a fork of pyExcelerator, so incorporating requires few code changes, but it is actively maintained: 您可能希望尝试一下xlrd ...(我相信)它是作为pyExcelerator的一个分支开始的,因此合并几乎不需要更改代码,但它得到了积极维护:

http://pypi.python.org/pypi/xlrd http://pypi.python.org/pypi/xlrd

Project website 项目网站

General info, release notes and history from the documentation 一般信息,发行说明和文档中的历史记录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM