假設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()