sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #41853
[Question #562214]: Loop through CSV file and incrementing variable
New question #562214 on Sikuli:
https://answers.launchpad.net/sikuli/+question/562214
I am using Sikuli 1.1.0
I have a a set of static data that I have put into a csv.
The csv has 3 columns and upto 20 rows.
I wish to apply each of the cells to a variable in a script which will do some testing.
I have been able to assign the first row to the variables I need to use but I have got myself completely confused on how to increment the selection by 1 row, so that when my first set of tests have completed I can repeat the same script with the next row of variables.
import csv
class ContactDetails():
def __init__(self, filename):
with open(filename, "r") as f_input:
csv_input = csv.reader(f_input)
self.details = list(csv_input)
def get_col_row(self, col, row):
return self.details[row-1][col-1]
data = ContactDetails("C:\\testclist.csv")
csvfile = list(csv.reader(open('C:\\testclist.csv')))
#csvdics = []
for row in csvfile:
Cruise = data.get_col_row(1, 2)
Cell = data.get_col_row(2,2)
cruisenum = data.get_col_row(3,2)
wait (4)
# start booking process direct into form
openApp(r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")
wait(5) # waits 5 seconds, I increased the wait to 7 seconds - just to be safe
type("l", KeyModifier.CTRL) # press lowercase L + CTRL
paste((Cruise)+Key.ENTER)
print Cell
print cruisenum
print "%s %s: %s" % (Cruise, Cell, cruisenum)
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.