コード例 #1
0
    def print_movie_lists_excel(self, movie_lists, movie_tag_lists):
        """

        :rtype : object
        """
        wb = Workbook(optimized_write=True)
        print ("print_movie_lists_excel")
        ws = []
        for i in range(len(movie_tag_lists)):
            ws.append(wb.create_sheet(title=movie_tag_lists[i].decode()))  # utf8->unicode
        for i in range(len(movie_tag_lists)):
            ws[i].append(["序号", "电影名", "评分", "评价人数", "类型", "年份", "导演", "演员", "五星", "四星", "三星", "二星", "一星", "推荐列表"])
            count = 1
            for bl in movie_lists[i]:
                print ("bl.len:", len(bl))

                # ws[i].append([count,bl[0],float(bl[1]),int(bl[2]),bl[3],(bl[4]),bl[5],bl[6],bl[7],bl[8],bl[9],bl[10],bl[11]])

                count += 1

            # 获取 存储路径
        f = contentClass()
        save_path = f.getContentForDouBan(2)
        print ("save path:", save_path)

        for i in range(len(movie_tag_lists)):
            save_path += "-" + movie_tag_lists[i].decode()
        save_path += ".xlsx"
        wb.save(save_path)
コード例 #2
0
def print_book_lists_excel(book_lists,book_tag_lists):
    wb=Workbook(optimized_write=True)

    print('start print_book_lists_excel')

    #have create succ in polen computer,so i commit them,2015-08-15 00:29:46
    # create_db()

    ws=[]
    for i in range(len(book_tag_lists)):
        ws.append(wb.create_sheet(title=book_tag_lists[i].decode())) #utf8->unicode
    for i in range(len(book_tag_lists)): 
        ws[i].append(['序号','书名','评分','评价人数','作者','出版社'])
        count=1
        for bl in book_lists[i]:
            ws[i].append([count,bl[0],float(bl[1]),int(bl[2]),bl[3],bl[4]])

            #解析 出版信息
            publisherInfo = bl[4].split('/')
            publisher = publisherInfo[0].split(' ')
            print('publish:',publisher)
            publisher = publisher[2]
            publishTime  = publisherInfo[1]
            price = publisherInfo[2]

            # saveDataForDouban(count,bl[0],str(bl[1]),int(bl[2]),bl[3],str(publisher),str(publishTime),str(price))

            count+=1

    # 获取 存储路径
    f =  contentClass()
    save_path= f.getContentForDouBan(BOOk_TYPE)
    print('save path:',save_path)

    for i in range(len(book_tag_lists)):
        save_path+=('-'+book_tag_lists[i].decode())
    save_path+='.xlsx'
    wb.save(save_path)
    print('save finish,at',save_path)