Python Forum

Full Version: How to removewhat is common from one text file using another text file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a file that contains the following text.

File1.txt

For all intents and purposes, the reason Mr. Henderson arrived late for work was due to the fact that he stopped at very many traffic lights that were red in colour.
I then have another file with the following text.

File2.txt

[ 4 , 0 , "For all intents and purposes, t" , "T" , 3 , "he reason Mr. " , 3 , "Henderson arrived late for work was " , 0 , "d" , "beca" , 3 , "u" , 2 , "s" , 3 , "e" , 1 , " to the fact that" , 3 , " he stopped at very many traffic lights that were red " , 1 , "in" , 3 , " " , 1 , "colour" , 3 , ". " , 4 , 4 ]

I wish to use File2.txt to remove what is common to file1.txt. Outputting the result to File3.txt.
The contents of File3.txt should when done look like this.

Mr. Henderson arrived late for work because he stopped at many red lights.
what have you tries so far?