I have two files 1st with necessary data: 1st file and 2nd with list of lines to keep: 2nd file
I have tried to make filtering by the python code:
import os.path
# loading the input files
output = open('descmat.txt', 'w+')
input = open('descmat_all.txt', 'r')
lists = open('training_lines.txt', 'r')
print "Test1"
# reading the input files
list_lines = lists.readlines()
list_input = input.readlines()
print "Test2"
output.write(list_input[0])
for i in range(len(list_lines)):
for ii in range(len(list_input)):
position = list_input[ii].find(list_lines[i][:-1])
if position > -1:
output.write(list_input[ii])
break
print "Test3"
output.close()
but this script cannot find any matches. What is the easiest solution to keep only the lines from the 1st file which are matching to the 2nd file?