← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #237635]: Use clients info from txt

 

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

RaiMan proposed the following answer:
--- the basic loop:

inp = open("path-to-file")
line = inp.readline()
seq = 0
while line:
    seq = seq +1
    line = line.strip()
    if seq == 1:
        print "name:", line
        # put your special treatment here
    elif seq == 2:
        print "street": line
        # put your special treatment here
    elif seq == 3:
        print "city:", line
        # put your special treatment here
    elif seq == 4:
        print "most:", line
        # put your special treatment here
    elif seq == 5:
        print "last:", line
        # put your special treatment here
        seq = 0
    line = inp.readline()
inp.close()

special treatments:
elements = line.split()
will seperate the line in whitespace delimited elements, and puts it in a list elements, that you might use to evaluate the special line types.

Another possibility is to use RegEx (module re), to grab the elements
from a line.

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