priceapi.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:priceAPI 作者: yorikvanhavre 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号