I am isolating two duplicate files and my problem is that one of the files gets a row, the other File does not exist, the difference stops I want to write / print the line and after that I will continue. F = open ("output", "w") test_lines =
Sample input
P> file1
  jack tom apple orange   file2
  jack apple ape mic   
 According to your comment, you line Do not want line by comparison. I think Python's  set  is most appropriate for your case. This is a snippet: 
  import re f1 = open ("file1", "r") f2 = open ("file2", "r") f = open ("output", " W ") test_lines = f1.readlines () correct_lines = f2.readlines () test_lines = set ([l.strip (). Partition (" (") [0] .replace (" "," "). Strip () For test_lines)] correct_lines = set ([l.strip (). Split ("(") [0]. ("", ""). (Strip for L in right_lines)) Print "expected:" Expected: Set (['Mike', 'App']), "Correct" and "Got: Set (['orange', 'Tom'])   
No comments:
Post a Comment