how to compare list to text file and delete missing entries
<p>If I have a list with different values like <code>Eind, Shf, Asuf</code>.
And a text file with</p>

<pre><code>20:36:00 - Baarn
20:36:00 - Enschede
20:37:00 - Eindhoven
20:37:00 - Eind
20:37:00 - Shf
20:37:00 - Asuf
20:38:00 - Nijmegen
</code></pre>

<p>How do I delete the values in the list from the text file but delete the whole line.</p>

<p>I would create a new file:</p>

<p>Given that you have a list like this</p>

<pre><code>to_delete = ['Eind', 'Shf', 'Asuf']
</code></pre>

<p>you can open both your current file and a new file and create a new version</p>

<pre><code>in_file = open('input.txt')
out_file = open('output.txt')
for line in in_file:
     last_word = line.split(' ')[-1]
     if not last_word in to_delete:
          out_file.write(line)
in_file.close()
out_file.close()
</code></pre>

<p>in this way, the new file has only the entries that don't match with the itemes in your list. In the code above I assume that your file has to check only the last word with whatever is in the list.</p>

python list text-files