def build(self):
import xlrd
tf = None
if not tf:
defaultlocation = os.path.dirname(os.path.abspath(__file__))+os.sep+"sources"+os.sep+"seinfra.xls"
if os.path.exists(defaultlocation):
print "building from ",defaultlocation
tf = defaultlocation
else:
tf = self.download()
if not tf:
return
f = xlrd.open_workbook(tf)
self.descriptions = []
self.values = []
self.units = []
self.codes = []
sh = f.sheets()[0]
for i in range(5,sh.nrows):
r = sh.row(i)
if (r[0].ctype == xlrd.XL_CELL_TEXT) and (r[1].ctype == xlrd.XL_CELL_TEXT) and (r[4].ctype == xlrd.XL_CELL_TEXT) and (r[5].ctype == xlrd.XL_CELL_NUMBER):
self.codes.append(r[0].value)
self.descriptions.append(r[1].value)
self.units.append(r[4].value)
self.values.append(r[5].value)
#f.close()
print "parsed data: ",len(self.codes),"/",len(self.descriptions),"/",len(self.values),"/",len(self.units)
评论列表
文章目录