sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #10204
Re: [Question #194613]: How to read line by line from a text file and store the content for later use (2)
Question #194613 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/194613
Status: Needs information => Answered
RaiMan proposed the following answer:
this is still the basic script template to read something line by line
in a list for later use:
I have used other variable names, to make it clearer
import os
idsList = [] # empty list/array
dir = "c:/folder/subfolder" # the folder, where your ids.txt is
idsFile = os.path.join(dir, "ids.txt") # makes a Windows filename
f = open(idsFile) # opens ids file
for line in f.readlines(): # reads line by line
id = line.strip() # get rid of newline
print id
idsList.append(id) # add id to list/array
f.close() # close file
# now you have all your ids in the list/array idsList
# Now you can add your putty loop
switchApp("putty.exe")
for id in idsList:
type("sho " + id + Key.ENTER)
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.