Unable validate a test case name inside a list of files

0 views
Skip to first unread message

dwarika Prasad

unread,
Aug 6, 2019, 11:42:59 PM8/6/19
to Lamp_tutorial
Hi All,

I am trying to validate a test case name inside a file but unable to iterate over the list of files by opening as a result test case name is being able get validated
import glob
import errno
import re
import csv
import openpyxl
import sys
import os
#Compairing with Data with a particular folder.
file1 = open('D:\study\Python\\Compairing_Data.txt', 'r')
f = file2 = file1.readlines()
li = []
li2 = []
for i in file2:
    if file2.index(i) % 2 != 0:
        li.append(i.rstrip())
    else:
        li2.append(i.rstrip())
result = zip(li2, li)

#Validating test case name
folder = os.listdir("D:\\study\\Python\\Battman_Solution")
count= 0
#print folder
for i in result:
    if i[1] in folder:
        print i[1]
        with open(i[1],'r') as f:
            if i[0] in f.readlines():
                b = "%s is present in %s" % (i[0], i[1])
                with open('D:\\study\\Python\\Final_Present_IN_GIT.txt', 'a') as f1:
                        f1.write(b + '\n')
    elif i[1] not in folder:
         with open('All_Robot_File_Data.txt','r') as f2:
             if i[0] in f2.readlines():
                 c = "%s is present in D:\\study\\Python\\Battman_Solution" % (i[0], i[1])
                 with open('D:\\study\\Python\\Final_Present_IN_GIT.txt', 'a') as f2:
                    f2.write(c + '\n')
    else:
        d = "%s is not present in D:\\study\\Python\\Battman_Solution" % (i[0])
        with open('D:\\study\\Python\\Final_Not_Present_IN_GIT.txt', 'a') as f3:
            f3.write(d + '\n')

Note : all files that mentioned in code is attached

Please help me on the same
Thanks and regards,
Dwarika Prasad Sahu
09884849768
Skype : Dwarika1988





Compairing_Data.txt
All_Robot_File_Data.txt
Battman_Solution.7z
Reply all
Reply to author
Forward
0 new messages