If answer is yes then skip, if answer is no then execute.

Asked by Stephan Timmers on 2018-01-09

This is a visualisation of the Excel sheet I am using:
I need Sikuli to execute the following:

If cell A1 = Yes then skip to next cell.
If cell A1 = No then copy C1

-----A-----------B-----------C------------
1---Yes--------Text--------Product
2---No---------Text--------Product
3---No---------Text--------Product
4---No---------Text--------Product
5---No---------Text--------Product
6---No---------Text--------Product
7---No---------Text--------Product

Would greatly appreciate it if someone could help me out writing the Python code for this.
Greetings,
Stephan

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2018-01-09
Last reply:
2018-01-10
RaiMan (raimund-hocke) said : #1

look here for how to directly access Excel sheets;
faq 2208

No visual programming nor keyboard simulation needed ;-)

Thanks I know that this Part doesnt need visual programming but the rest of my script does.
Could you please help me with a part of code after the import xldr piece?
A link to a tutorial about xldr conditional looping or w/e is fine aswell!
I have been looking for hours on Reddit and Discord of Python code etc but no luck.
Help a noobie out

masuo (masuo-ohara) said : #3

That is "xlrd" not "xldr".

http://xlrd.readthedocs.io/en/latest/api.html

[example codes:]
import xlrd
import datetime

book = xlrd.open_workbook("C:\\temp\\book1.xlsx")
sheet = book.sheet_by_index(0)
for col in range(sheet.ncols):
    for row in range(sheet.nrows):
        dtype = sheet.cell_type(row,col)
        value = sheet.cell(row,col).value
        if dtype == 1: #TEXT
            print "col:%d row:%d value:%s" % (col,row,value)
        elif dtype == 2: #NUMBER
            print "col:%d row:%d value:%d" % (col,row,value)
        elif dtype == 3: #DATE
            s = datetime.datetime(*xlrd.xldate_as_tuple(value,book.datemode)).strftime("%Y/%m/%d")
            print "col:%d row:%d value:%s" % (col,row,s)

Can you help with this problem?

Provide an answer of your own, or ask Stephan Timmers for more information if necessary.

To post a message you must log in.