Quantcast

xlrd处理excel文件

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

xlrd处理excel文件

hejibo
大家好,
     我想用xlrd来读excel文件,可是遇到了一些问题,请牛人指点一下。谢谢
 
#!/usr/bin/env python
#coding=utf-8
import xlrd
filefilter = open("fixationfilter1.txt",'a')
data=xlrd.open_workbook("try.xls")
sh=data.sheet_by_index(0)
print >>filefilter,sh.cell_value(rowx=1,colx=1)
filefilter.close()
错误报告为:
 
Traceback (most recent call last):
  File "D:/Program Files/python 2.4.3/py2exe code/tryxlrd.py", line 7, in -toplevel-
    data=xlrd.open_workbook("try.xls")
  File "D:\Program Files\python 2.4.3\Lib\site-packages\xlrd\__init__.py", line 370, in open_workbook
    biff_version = bk.getbof(XL_WORKBOOK_GLOBALS)
  File "D:\Program Files\python 2.4.3\Lib\site-packages\xlrd\__init__.py", line 1323, in getbof
    raise XLRDError('Expected BOF record; found 0x%04x' % opcode)
XLRDError: Expected BOF record; found 0x4b50

--
Best Regards,

         He Jibo
       [hidden email]
[hidden email]


---------------------------
He Jibo
Department of Psychology,
Beckman Institute for Advanced Science and Technology
University of Illinois, Urbana Champaign,
603 East Daniel St.,
Champaign, IL 61820
Tel: 217-244-4461(office)
217-244-6763(lab)
Email: [hidden email]

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Loading...