wb=xl.load_workbook(datafile)
ws=wb['Sheet1']
#insert a new column #5
ws.insert_cols(idx=5,amount=1)
wb.save(datafile)
mr=ws.max_row
#move cells
for i in range (1,mr+1):
v=ws.cell(row = i+1,column=4)
ws.cell(row=i,column =5).value=v.value
wb.save(datafile)
wb.close
wb=xl.load_workbook(datafile)
ws=wb['Sheet1']
#insert a new column #5
ws.insert_cols(idx=5,amount=1)
#Calculate total number of rows
mr=ws.max_row
#move cells
for i in range (2,mr,2):
ws.cell(row=i,column=5).value=ws.cell(row=i+1,column=4).value
#delete unwanted rows
for i in range (2,mr,2):
ws.delete_rows(idx=i+1,amount=1)
wb.save(datafile)
wb = xl.load_workbook(datafile)
ws = wb['Sheet1']
# insert a new column #5
ws.insert_cols(idx=5, amount=1)
# wb.save(datafile) # <--- not necessary just save at the end
mr = ws.max_row
# move cells
# Move and delete the rows by making the changes from the bottom up