I am trying to open an excel file then insert data into the 2nd row (pushing all existing data below the 1st row down by one row). I don't want to overwrite any existing data, just add the new data and push the existing data down by one row.
Here is some code I'm using to get me started:
import xlrd
import xlwt
from xlutils.copy import copy
def save_test_log(test_log_path, selected_save_path, test_type, date_n_time, tester):
rb = xlrd.open_workbook(test_log_path,formatting_info=True)
r_sheet = rb.sheet_by_index(0) # sets r_sheet to be the 1st sheet
r = r_sheet.nrows # gets the number of rows in the 1st sheet.
wb = copy(rb) # coppies contents of rb to a write file so we can edit it.
sheet = wb.get_sheet(0) # select the 1st sheet in wb
This is about as far as I get. I know how to add rows to the end of the sheet but I have no idea how to "insert" rows of existing data into the sheet.
Do you have the answers I seek?
Thanks,