title: Python script syntax error
body: <p>My experience with Python is limited, so I've been using other StackOverflow questions/answers to guide my script, primarily this one: <a href="https://stackoverflow.com/questions/5268929/python-comparing-two-csv-files-and-searching-for-similar-items">Python: Comparing two CSV files and searching for similar items</a> and this one: <a href="https://stackoverflow.com/questions/16271331/how-to-delete-rows-csv-in-python">How to Delete Rows CSV in python</a><br>
  I am attempting to match IDs from two separate csvs each of which looks roughly like: </p>
  
  <pre><code>ID trip  date     location
  1   1    1/1/2009 384
  1   2    1/3/2009 384
  1   3    1/7/2009 467
  2   1    1/2/2009 842
  2   2    1/3/2009 362
  </code></pre>
  
  <p>I am trying to match based on the trips each ID takes, so for ID 1 in csv1 I look for all IDs in csv2 that have a trip on 1/1/2009 from location 384, then from that list I look for which ones also have a trip on 1/3/2009 from location 384 and so on until there is only one ID from csv2 that matches the ID in csv1: a match. Here is the code I have:  </p>
  
  <pre><code>import csv, sys, fileinput
  
  f1 = open('personal2009.csv', 'rb')
  f2 = open('company2009.csv', 'rb')
  
  c1 = csv.reader(f1)
  c2 = csv.reader(f2)
  
  vmslist = [row for row in c2]
  
  matchDict = {}
  ID_list = []
  ID = 0
  for log_row in c1:
      if log_row[0] != ID:
          ID = log_row[0] 
          matchlist = csv.writer(open("matchlist" + str(ID) + ".csv", "wb")
          for vms_row in vmslist:
              if vms_row[2] == log_row[2] and vms_row[3] == log_row[3]:
                  matchlist.writerow(vms_row)
      elif log_row[0] in ID_list:
          continue
      else:
          f = fileinput.input("matchlist" + str(ID) + ".csv", inplace=True)
          w = csv.writer(sys.stdout)
          for match_row in csv.reader(f):
              if match_row[2] == log_row[2] and match_row[3] == log_row[3]:
                  w.writerow(row)
          if len(list(w)) == 1:
              matchDict[str(ID)] = match_row[0]
              vessel_list.append(str(ID))
  
  f1.close()
  f2.close()
  matchlist.close()
  </code></pre>
  
  <p>Whenever I try to debug or run the code in PythonWin, I get the error <strong>Failed to run script - syntax error - invalid syntax</strong> in the footer of PythonWin and the cursor stops at the row: <strong>for vms_row in vmslist:</strong><br>
  I get no further explanation or error information than that. I have tried renaming all my variables and nothing gets past this error, so I have to conclude I am trying to do something incredibly silly and I can't see what it is. Any thoughts?</p>