← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #236949]: How to compare the string from two different text file?

 

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

    Status: Answered => Open

koventhan is still having a problem:
Not understanding this script. Can you please give little bit
information,

my_dir = "C:\\Program Files\\Sikuli X\\"

1st File- Student1_list.txt

its has below informations,

Student Name - Kumar
Student ID- 12345
Student percentage - 75%
...
...
...
...
etc

2nd File - Student2_list.txt

its has below informations,

Student Name - Siva
Student ID- 6789
Student percentage - 90%
...
...
...
...
etc

please let me know below script is fine or not?


def getName(file):
    f = open(file)
    name = ""
    for line in f.readlines():
        if line.count("Student Name") == 0: continue
        (head, name) = line.split("-")
        name = name.strip()
        break
    f.close()
    return name

file1 = "C:\\Program Files\\Sikuli X\\Student1_list.txt"
file2 = "C:\\Program Files\\Sikuli X\\Student2_list.txt"

name1 = getName(file1)
name2 = getName(file2)
if name1 == name2:
    print "we have a match:", name1, "in:" file1, "and:", file2
else:
    print "different names:", name1, name2, "in:" file1, "and:", file2

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