title: Loop though one csv file and use the values as parameters to find records in another csv file
body: <p>I have two csv files that look like this:</p>
  <p>table 1:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ID</th>
  <th>Urgent number</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>123</td>
  <td>2</td>
  </tr>
  <tr>
  <td>234</td>
  <td>3</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>table 2:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ID</th>
  <th>Part</th>
  <th>Date</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>123</td>
  <td>A</td>
  <td>01/01/2022</td>
  </tr>
  <tr>
  <td>123</td>
  <td>A</td>
  <td>01/01/2022</td>
  </tr>
  <tr>
  <td>123</td>
  <td>A</td>
  <td>01/01/2022</td>
  </tr>
  <tr>
  <td>123</td>
  <td>A</td>
  <td>01/01/2022</td>
  </tr>
  <tr>
  <td>123</td>
  <td>A</td>
  <td>01/01/2022</td>
  </tr>
  <tr>
  <td>234</td>
  <td>B</td>
  <td>01/01/2022</td>
  </tr>
  <tr>
  <td>234</td>
  <td>B</td>
  <td>01/01/2022</td>
  </tr>
  <tr>
  <td>234</td>
  <td>B</td>
  <td>01/01/2022</td>
  </tr>
  <tr>
  <td>234</td>
  <td>B</td>
  <td>01/01/2022</td>
  </tr>
  <tr>
  <td>234</td>
  <td>B</td>
  <td>01/01/2022</td>
  </tr>
  <tr>
  <td>234</td>
  <td>B</td>
  <td>01/01/2022</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I'm trying to take the first table and use the ID to search the second table for the number of records that are in the 'urgent number' column and then assign a value to a new column. table 2 can have more records than the 'urgent number' in table 1 so I’m guessing that i need to use loops to do it.</p>
  <p>I've put the data into data frames and found some code that has helped me loop through the first table, but where im stuck now using this in another loop to search the second table.</p>
  <pre><code>    table1 = pd.read_csv (r'CustomerFloat.csv')
      table2 = pd.read_csv (r'EKanbanOrderbook.csv')
  
      content_of_rows = {}
      for row in CF.itertuples():
          index = row[0]
          uniqueID = row[1]
          urgentDeficit = row[6]
     
          content_of_rows.update({index:{&quot;uniqueID&quot;:uniqueID, 
      &quot;urgentDeficit&quot;: urgentDeficit}})
      #print(content_of_rows)
  
      for row in content_of_rows:
      
          print(content_of_rows[row])
  
  </code></pre>
  <p>I tried this to get it to start looping through the second table and it just returns 0 and I’m not sure what else to try or search to solve this.</p>
  <pre><code>    for row in content_of_rows:
          i = 0
          while i &lt; urgentDeficit:
          
              print(urgentDeficit)
              i += 1  
  
  </code></pre>
  <p>Can anyone point me in the right direction?</p>
  <p>The output should look like this:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ID</th>
  <th>Part</th>
  <th>Date</th>
  <th>urgent</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>123</td>
  <td>A</td>
  <td>01/01/2022</td>
  <td>x</td>
  </tr>
  <tr>
  <td>123</td>
  <td>A</td>
  <td>01/01/2022</td>
  <td>x</td>
  </tr>
  <tr>
  <td>123</td>
  <td>A</td>
  <td>01/01/2022</td>
  <td>x</td>
  </tr>
  <tr>
  <td>123</td>
  <td>A</td>
  <td>01/01/2022</td>
  <td></td>
  </tr>
  <tr>
  <td>123</td>
  <td>A</td>
  <td>01/01/2022</td>
  <td></td>
  </tr>
  <tr>
  <td>234</td>
  <td>B</td>
  <td>01/01/2022</td>
  <td>x</td>
  </tr>
  <tr>
  <td>234</td>
  <td>B</td>
  <td>01/01/2022</td>
  <td>x</td>
  </tr>
  <tr>
  <td>234</td>
  <td>B</td>
  <td>01/01/2022</td>
  <td></td>
  </tr>
  <tr>
  <td>234</td>
  <td>B</td>
  <td>01/01/2022</td>
  <td></td>
  </tr>
  <tr>
  <td>234</td>
  <td>B</td>
  <td>01/01/2022</td>
  <td></td>
  </tr>
  <tr>
  <td>234</td>
  <td>B</td>
  <td>01/01/2022</td>
  <td></td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Thanks</p>