title: How to combine lines in two files with condition in python?
body: <p>I need to combine lines in two files, basing in the condition, that in the line of one of the files is a part of the line of the second file.</p>
  
  <p>A part of the first file:</p>
  
  <pre>
  12319000    -64,7357668067227   -0,1111052148685535  
  12319000    -79,68527661064425  -0,13231739777754026  
  12319000    -94,69642857142858  -0,15117839559513543    
  12319000    -109,59301470588237 -0,18277783185642743  
  12319001    99,70264355742297   0,48329515727315125  
  12319001    84,61113445378152   0,4060446341409862  
  12319001    69,7032037815126    0,29803063228455073  
  12319001    54,93886554621849   0,20958105041136763  
  12319001    39,937394957983194  0,13623056582981297  
  12319001    25,05574229691877   0,07748669438398018  
  12319001    9,99716386554622    0,028110643107892755  
  </pre>
  
  <p>A part of the second file:</p>
  
  <pre>
  12319000.abf    mutant  1  
  12319001.abf    mutant  2  
  12319002.abf    mutant  3  
  </pre>
  
  <p>I need to create a file, where the line consists of this: all line from the first file and everything from the line of the second one. except for the filename in the first column.</p>
  
  <p>As you can see, there are more, than one line in the first file, cooresponding to a line in the second one. I need that operation to be done with each line, so the output should be like this:</p>
  
  <pre>
  12319000    -94,69642857142858  -0,15117839559513543  mutant    1  
  12319000    -109,59301470588237 -0,18277783185642743  mutant    1  
  12319001    99,70264355742297   0,48329515727315125  mutant 2  
  12319001    84,61113445378152   0,4060446341409862  mutant  2  
  </pre>
  
  <p>I've written this code:</p>
  
  <pre><code>oocytes = open(file_with_oocytes, 'r')  
  results = open(os.path.join(path, 'results.csv'), 'r')  
  results_new = open(os.path.join(path, 'results_with_oocytes.csv'), 'w')  
  for line in results:  
      for lines in oocytes:  
          if lines[0:7] in line:  
              print line + lines[12:]  
  </code></pre>
  
  <p>But it prints out this, and nothing more, thow there are 45 line in the first file:</p>
  
  <pre>
  12319000    99,4952380952381    0,3011778623990699
      mutant  1  
  
  12319000    99,4952380952381    0,3011778623990699
      mutant  2  
  
  12319000    99,4952380952381    0,3011778623990699
      mutant  3  
  </pre>
  
  <p>What is wrong with the code?
  Or it should be done somehow completely differently?</p>