title: Extracting selected columns from a table using BeautifulSoup
body: <p>I am trying to extract the first and third columns of <a href="http://www.samhsa.gov/data/NSDUH/2k10State/NSDUHsae2010/NSDUHsaeAppC2010.htm#tabC.7">this data table</a> using BeautifulSoup. From looking at the HTML the first column has a <code>&lt;th&gt;</code> tag. The other column of interest has as <code>&lt;td&gt;</code> tag. In any case, all I've been able to get out is a list of the column with the tags. But, I just want the text. </p>
  
  <p><code>table</code> is already a list so I can't use <code>findAll(text=True)</code>. I'm not sure how to get the listing of the first column in another form. </p>
  
  <pre><code>from BeautifulSoup import BeautifulSoup
  from sys import argv
  import re
  
  filename = argv[1] #get HTML file as a string
  html_doc = ''.join(open(filename,'r').readlines())
  soup = BeautifulSoup(html_doc)
  table = soup.findAll('table')[0].tbody.th.findAll('th') #The relevant table is the first one
  
  print table
  </code></pre>