Search code examples
pythonseleniumxlrd

form automation 12 digit number extracting with decimal


I'm working on a form automation script in python. It extracts the data from a excel file and fills out in a online form. The problem I'm facing is with a 12-digit number in a column in excel file data. The number seems fine the excel file by using custom setting for it but when the python script extracts the data it appears as a hexadecimal number. I've tried using many things but nothing really seems to work. I'm using xlrd.

My current script

stradh = str(sheet.cell(row,col).value) 
browser.find_element_by_id('number').send_keys(stradh)

Number in excel file:

357507103697

Number when extracting from python script:

3.57507103697e+11

Thank you.


Solution

  • you need the decimal module and convert no from scientific no

    from xlrd import *
    import decimal 
    
    workbook = open_workbook('temp.xlsx')
    
    sheet = workbook.sheet_by_index(2)
    
    value = sheet.cell_value(0, 0)
    
    print decimal.Decimal(value)