Python使用pandas逐行读取Excel

1. 安装pandas

pip install pandas -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

2. 逐行读取数据示例

    try:
        sheet = pandas.read_excel("my_excel.xlsx", "my_sheet")
        for row in sheet.index.values :
            doc = dict()
            doc['key1'] = sheet.iloc[row, 0]
            doc['key2'] = sheet.iloc[row, 1]
    except Exception as e:
        print(e)
    return

 

你可能感兴趣的:(Python基础)