title: combine selected lines/rows within a csv file
body: <p>I need to combine lines (<code>$GPGGA</code> and <code>$GPVTG</code>) within a csv file with python and have a problem. The csv file looks like this:</p>
  
  <pre><code>~11:16:04.831,$GPGGA,091606.00,5149.28020915,N,01140.54074205,E
  ~11:16:04.861,$GPVTG,40.8,T,,,000.05,N,000.09,K,D*75
  ~11:16:05.833,$GPGGA,091607.00,5149.28020818,N,01140.54074319,E
  ~11:16:05.863,$GPVTG,40.8,T,,,000.01,N,000.01,K,D*79
  </code></pre>
  
  <p>I tried with</p>
  
  <pre><code>eingabe = sys.argv[1]
  with open(eingabe, "rb") as file:   
      datareader = csv.reader(file)
      for row in datareader:
          if "$GPGGA" in row:
              col1 = row[0], row[1], row[3], row[5]
          if "$GPVTG" in row:
              col2 = row[0], row[1], row[2]
          print col1 + col2
  </code></pre>
  
  <p>The result is only the final line, but I need all of them </p>
  
  <p>('~11:16:08.827', '$GPGGA', '5149.28021200', '01140.54075064', '~11:16:08.867', '$GPVTG', '40.8')</p>
  
  <p>How do I go about achieving this?</p>