Compare two text files and return the difference (case insensitive)
<p>I'm new to Python programming so forgive me if my code is not efficient, etc. I need to compare text file B with text file B and print the results out to another file. Simply put, result C = text file A - text file B. </p>

<p>I have the following code which works, however, there are duplicate results due to upper and lower cases. How can I make it such that my program can compare it without case sensitivity?</p>

<pre><code>#!/usr/local/bin/python -u

file1='A_GAGL.txt'
file2='B_GGL.txt'

def key(line):
  return tuple(line.strip().split()[0:2])

def make_key_set(file_path):
  return set(key(line) for line in open(file_path))


def filtered_lines(file_path1, file_path2):
  key_set = make_key_set(file_path2)
  return (line for line in open(file_path1) if key(line) not in key_set)

if __name__ == "__main__":
  file3 = open("file4.txt", "w")
  for line in filtered_lines(file1, file2):
      file3.write(line)
  file3.close()
</code></pre>

<p>Many thanks in advance</p>
