#-*- coding: utf-8 -*-
from __future__ import with_statement
import xlrd
import time,datetime
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
with open('sc.txt') as f:
---- for line in f:
--------book = xlrd.open_workbook(line.strip())
--------sh = book.sheet_by_index(0)
--------acc = sh.cell_value(0,1)
--------acd = datetime.datetime.strptime(acc, '%m-%d %H:%M:%S')
--------acd = acd.strftime('%m%d%H%M')
--------ace = str(acd+'sh')
-------- a=file(ace+".txt",'w')
--------for rx in range(sh.nrows):
------------bxd = sh.row(rx)
------------a.write(str(bxd[0])+str(bxd[2])+'\n')
--------a.close()
###错误下面。用的是xp系统。python2.5
Traceback (most recent call last):
File "sa12.py", line 11, in <module>
book = xlrd.open_workbook(line.strip())
File "C:\Python25\Lib\site-packages\xlrd\__init__.py", line 443, in open_workb
ook
ragged_rows=ragged_rows,
File "C:\Python25\Lib\site-packages\xlrd\book.py", line 88, in open_workbook_x
ls
biff_version = bk.getbof(XL_WORKBOOK_GLOBALS)
File "C:\Python25\Lib\site-packages\xlrd\book.py", line 1254, in getbof
bof_error('Expected BOF record; found %r' % self.mem[savpos:savpos+8])
File "C:\Python25\Lib\site-packages\xlrd\book.py", line 1248, in bof_error
raise XLRDError('Unsupported format, or corrupt file: ' + msg)
xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record;
found '<html>\r\n'