my code in Python should generate a continous Serial-No. after doing a raw input and save it in a new row in Excel. But i have one problem: When i run the programme, it always overwrites the last run. So how can i open (read) the existing Excelsheet, write new data below the existing data without overwriting?
My code is like this:
import xlsxwriter
workbook = xlsxwriter.Workbook('file.xlsx')
worksheet = workbook.add_worksheet()
row_count = 0
col = 0
n1 = 99
n2 = 99
n3 = 99
value_manufacturer = "0"
while True:
inp = raw_input('Choose the system:')
if inp == '1':
print 'HS25 is selcted'
serial_no_HS25 = "23"
break
while True:
inp = raw_input('Is the system OK?')
if inp == '4':
n1 += 1
print (serial_no_HS25 + value_manufacturer + str(n1))
row_count += 1
if (n1) <= 999:
worksheet.write(row_count, col, serial_no_HS25 + value_manufacturer + str(n1))
worksheet.write('C3', row_count)
else:
worksheet.write(row_count, col, (n1)
else:
print ('Wrong input for HS25')
The code works but how to insert any memory funtion or something similar? Thank you for your help!!!