← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #153770]: Need to take input from file

 

Question #153770 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/153770

NewUser2 posted a new comment:
Hi Raimon,

Thankyou for your repyly, before I could see your reply I had tried the
following

fd = open("c:\\test\\test.txt", 'r')
lines = fd.readlines()
print lines[0].split(":")[1]
print lines[1].split(":")[1]
print lines[2].split(":")[1]
print lines[3].split(":")[1]

It seems to be working pretty much as expected. Please let me know if it is a good way to go. 
Also I am having another struggle while tryin to write to a file 

I am trying the following

my_dir = "c:\\test\\"
el = "\n" 

my_file=file(my_dir + "Result.txt", "w")
my_file.write(el+"\n This Test case is Pass \n") 
my_file.close

The two challanges that I am facing here is ..
1) Even though when I am saying file.close , it is not actually closing the file I have to close Sikulli in order to view the contents of the file 
2)When I am trying to write to the file, Sikulli is erasing the previous contents and then writing the new line.I want to retain the contents of the file and write on a new line 

What am I missing. 
Please let me know if I should be writing a different question for this.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.