title: Python Compare two CSV Files line by line
body: <p>I currently have a version of a script that compares two csv files by reading both into a list/set one after the other.
  However, the csvs are currently too large for memory, so I would like to iterate line by line and print out lines which are different.</p>
  
  <p>i can't do two loops of csvreaders because then the inner one will read the whole file while the outer loop will be on the first line</p>
  
  <p>i'd rather do this than diff so i can print additional info out when lines don't match to figure out why</p>
  
  <p>Edit: so far i did something like this but the csvs are too large to load into a list all at once</p>
  
  <pre><code>def readFile(filename,columns):
  mylist=[]
      with open(filename,'rb') as f:
                  reader = csv.reader(f)
                  for line in reader:
                      mylist.append(tuple(line[i] for i in columns))
      return mylist
  
  mylist1=readFile(filename1,columns)
  mylist2=readFile(filename2,columns)
  diff1=diff(mylist1,mylist2)
  diff2=diff(mylist2,mylist2)
  </code></pre>