How to split a file in python
<p>I am trying to split 2 lists, compare them and make a new list without the succesfully compared items in 2 lists.</p>

<p>So lets say 
List_1.txt =</p>

<pre><code>Failed = abc
Failed = hfi
Failed = kdi
</code></pre>

<p>and List_2.txt = </p>

<pre><code>1:1:1 - jdsfjdf
2:2:2 - iidf
3:3:3 - abc
6:3:1 - hfi
8:2:1 - kdi
3:1:5 - dua
3:1:2 - dfh
</code></pre>

<p>I want to compare those lists and make a new_list2 without the list_1 entries.</p>

<p>what I tried was:</p>

<pre><code>treinrit = open('List_1', 'r')
lijna = treinrit.readlines()
treinrit.close()

annuleer_treinrit = open('List_2', 'r')
lijnb = annuleer_treinrit.readline()
annuleer_treinrit.close()

lijsta = []
lijstb = []

for a in lijna:
    clean = a.split(' - ')
    print(lijsta)

for b in lijnb:
    lijstb.append(lijnb.split(": "))
</code></pre>

<p>I just cant get the list to split properly. I only need the last bit of each file to compare but I don't know how.</p>

<pre><code>with open('File1', 'r') as f1:
    f1_stored = []
    for line in f1:
        f1_stored.append(line.split('=')[1].strip())
    with open('File2', 'r') as f2;
        output = []
        for line in f2:
            if not any(failed in line for failed in f1_stored):
                output.append(line)
</code></pre>

<p>The do what you want with <code>output</code></p>

python list file split