假设excel中只有一个表单,内容如下:
需求是读取excel,转换成map[old_id] = new_id
import pandas as pd
import xlrd
def read_from_excel():
df = pd.read_excel('/Users/zdchu/Downloads/superStarTitle.xlsx')
myMap ={}
for index, row in df.iterrows():
newId = row['new_id']
oldId = row['old_id']
myMap[oldId] = newId
print(myMap)
if __name__ == '__main__':
read_from_excel()