Value is not getting matched when comma inserted.

Asked by Subhasree Mohapatra

I took a value by region.text()= 222.3 converted it to float and then compared with 222.34 , It showed mismatch. But the I gave the value as 2,22.34 , the value is showing as matched.I gave another value 2,222.34, then it also showed as matched which is incorrect.Kindly advice

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Eugene S (shragovich) said :
#1

Hi,

Can you please show how exactly you compare these values?

Revision history for this message
Subhasree Mohapatra (mohapatra-subhasree13) said :
#2

The code is
dir_xl ="C:\\Program Files\\SIKULI\\Lib\\xlrd"
dir_xw ="C:\\Program Files\\SIKULI\\Lib\\xlwt"
dir_xu="C:\\Program Files\\SIKULI\\Lib\\xlutils"
import xlutils
import xlrd
import xlwt
i=222.43
j=2222.43
k=2222.43
book= xlrd.open_workbook ( "C:\Users\Subhasree\Desktop\Values.xls" )
sheet = book.sheet_by_index(0)
a=float(sheet.cell_value(0,0))
print a
if(a==i):
    print("pass")
else:
    print ("fail")
if(a==j):
    print("pass")
else:
    print ("fail")
if(a==k):
    print("pass")
else:
    print ("fail")

Result is :

2222.43
fail
pass
pass

The moment i change the value to k=2,222.43
result is:

2222.43
fail
pass
fail

Revision history for this message
RaiMan (raimund-hocke) said :
#3

no magic - just Python:

print k

would have revealed that
k = 2,222.43

results in k being a list containing the 2 values
(2, 222.43)

and hence
a == k

always yields False.

Revision history for this message
RaiMan (raimund-hocke) said :
#4

BTW: a shortcut:
print "pass" if a==k else "fail"

Can you help with this problem?

Provide an answer of your own, or ask Subhasree Mohapatra for more information if necessary.

To post a message you must log in.