-2

I am writing a selenium script where I need to store username password information of all the accounts I am creating. So I am using xlrd and xlwt to write information in an excel file but I am not able to find a way how script automatically detects next available row in the sheet and writes the info there. I am very new to Python.

Thanks in advance.

ErmIg
  • 3,980
  • 1
  • 27
  • 40

1 Answers1

2

You can get the number of rows and append information like this:

file = xlrd.open_workbook('accounts.xls', formatting_info=True)
row_number = file.sheet_by_index(0).nrows
sheet = wb.get_sheet(0) 
sheet.write(row_number, 0, 'blabla') 
Martin Evans
  • 45,791
  • 17
  • 81
  • 97
mdegis
  • 2,078
  • 2
  • 21
  • 39
  • Thanks for your answer, @mdegis `AttributeError: 'str' object has no attribute 'sheet_by_index'` is the error I am getting. I am adding following libs. `from xlrd import * from xlutils.copy import copy from xlwt import * import os.path` Can you tell me what am I missing – Ihsan Ahmed Zaheer Mar 23 '17 at 10:40