title: How do I extract table data in pairs using BeautifulSoup?
body: <p>My data sample :</p>
  
  <pre><code>&lt;table id = "history"&gt;
  &lt;tr class = "printCol"&gt;
  &lt;td class="name"&gt;Google&lt;/td&gt;&lt;td class="date"&gt;07/11/2001&lt;/td&gt;&lt;td class="state"&gt;
  &lt;span&gt;CA&lt;/span&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr class = "printCol"&gt;
  &lt;td class="name"&gt;Apple&lt;/td&gt;&lt;td class="date"&gt;27/08/2001&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr class = "printCol"&gt;
  &lt;td class="name"&gt;Microsoft&lt;/td&gt;&lt;td class="date"&gt;01/11/1991&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Beautifulsoup code :</p>
  
  <pre><code>table = soup.find("table", id = "history")
  
  rows = table.findAll('tr')
  for tr in rows:
      cols = tr.findAll('td')
      for td in cols:
          print td.find(text=True)
  </code></pre>
  
  <p>Desired Output for MySQL storage (list):</p>
  
  <pre><code>['Google|07/11/2001|CA', 'Apple|27/08/2001', 'Microsoft|01/11/1991']
  </code></pre>
  
  <p>Output I have (difficult to associate the right date to the right company) :</p>
  
  <pre><code>Google
  07/11/2001
  
  
  Apple
  27/08/2001
  Microsoft
  01/11/1991
  </code></pre>
  
  <p>I wrote a function to extract elements from each <em>tr</em> but I thought there is a much more efficient way of doing it all in the original <em>for</em> loop. I want to store them in a list as data pairs. Thoughts?  </p>