Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

compare two text files

Avatar of Suhas .
Suhas .Flag for United States of America asked on
Python
2 Comments1 Solution556 ViewsLast Modified:
Hi Experts,
I am new to Python. The query is to Compare the 4th filed of two text files if the difference is greater than or less than 15%, then we need to print the filenames.

The two text files are attached and the code i tried is also attached.
arr1 = []
arr2 = []


for line1 in open("testReport_flame3_0202.txt"):
    linesa= line1.strip().split(",")
    arr1.append(linesa[4])
for line2 in open("testReport_flame3_0209.txt"):
    linesb= line2.strip().split(",")
    #print linesb[4]
    arr2.append(linesb[4])

lenth = len(open("testReport_flame3_0202.txt").readlines())

for i in range(1,lenth):
   if((((arr1[i] - arr2[i])/arr1[i])*100) > 15):   # failing at this step
       print i

# after this i am not getting how to fetch the respective filename
testReport-flame3-0202.txt
testReport-flame3-0209.txt
ASKER CERTIFIED SOLUTION
Avatar of mish33
mish33Flag of United States of America imageSoftware Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers