Hi i've been using xlsxwriter to scrap some data. I've been identifying data via xpaths -> text. As shown in the code below. I've been trying to use xlsxwriter to perform some average across some cells. However the output excel file I get "#DIV/0!" in cell G2 but when I double click on each individual cell twice, that cells then gets averaged, I have to do this for all the cells I'm averaging. Any idea how I can over come this issue?
for elem in driver.find_elements_by_xpath('//*[@id="financials_table_ratio"]/tbody/tr[45]/td[2]'):
PER1=(elem.text)
for elem in driver.find_elements_by_xpath('//*[@id="financials_table_ratio"]/tbody/tr[45]/td[3]'):
PER2=(elem.text)
for elem in driver.find_elements_by_xpath('//*[@id="financials_table_ratio"]/tbody/tr[45]/td[4]'):
PER3=(elem.text)
for elem in driver.find_elements_by_xpath('//*[@id="financials_table_ratio"]/tbody/tr[45]/td[5]'):
PER4=(elem.text)
worksheet.write('B2',PER)
worksheet.write('C2',PER1)
worksheet.write('D2',PER2)
worksheet.write('E2',PER3)
worksheet.write('F2',PER4)
worksheet.write_formula('G2', '=average(C2:F2)')