excel.py 文件源码

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

项目:SampleApp-QuickBooksV3API-Python 作者: IntuitDeveloper 项目源码 文件源码
def load_excel():
    wb = openpyxl.load_workbook(filename=excel_file)
    ws = wb['data']

    # Parse data from Excel file
    dict_list = []
    keys = {'A': 'Id', 'B': 'Full Name', 'C': 'Email', 'D': 'Phone'}
    for row in ws.iter_rows(min_row=2, max_col=4):
        d = {}
        for cell in row:
            if cell.column == 'A' and cell.value == None:
                break
            elif cell.column != 'A' and cell.value == None:
                d[keys[cell.column]] = ''
            else:
                d[keys[cell.column]] = str(cell.value)

        if len(d.keys()) != 0:
            dict_list.append(d)
    return dict_list

# Update lead in excel worksheet and working dictionary
# Removing from excel leaves a blank row in the excel
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号