title: Error while reading compressed CSV file from URL with pandas.read_csv
body: <p>I'm trying to use <code>pandas.read_csv</code> to read bz2-compressed CSV files from a URL (in this case, a GitHub raw URL) from within an IPython notebook, but I get the following error:</p>
  
  <p><code>Python cannot read bz2 from open file handle</code>. </p>
  
  <p>I've done some research and I can't seem to figure out what's wrong. I've tried manually decompressing the bz2 files, and I know they aren't corrupted or otherwise bad, and I also know that the URLs are correctly formatted - if I enter them into my browser, it downloads the file correctly.</p>
  
  <p>Here's the code from my IPython notebook:</p>
  
  <pre><code>import pandas, bz2, urllib2
  datafiles = {}
  for filename in csvData['Filename']:
      csvUrl = 'https://raw.github.com/hawkw/traverse/master/data/' + filename
      try:
          datafiles[filename] = pandas.read_csv(csvUrl, compression='bz2')
          print (datafiles[filename])
      except Exception as e:
          print("Caught error \"{error}\" at {url}".format(error=e, url=csvUrl))
  </code></pre>
  
  <p>And the output:</p>
  
  <pre><code>Caught error "Python cannot read bz2 from open file handle" at https://raw.github.com/hawkw/traverse/master/data/-Users-hawk-_2014-02-05.csv.bz2
  Caught error "Python cannot read bz2 from open file handle" at https://raw.github.com/hawkw/traverse/master/data/-Users-Owner_2014-02-05.csv.bz2
  Caught error "Python cannot read bz2 from open file handle" at https://raw.github.com/hawkw/traverse/master/data/-Users-will_2014-02-05.csv.bz2
  Caught error "Python cannot read bz2 from open file handle" at https://raw.github.com/hawkw/traverse/master/data/-Users-hawk_2014-02-06.csv.bz2
  Caught error "Python cannot read bz2 from open file handle" at https://raw.github.com/hawkw/traverse/master/data/-Users-hawk-Documents_2014-02-06.csv.bz2
  Caught error "Python cannot read bz2 from open file handle" at https://raw.github.com/hawkw/traverse/master/data/-home-w-weismanm_2014-02-05.csv.bz2
  Caught error "Python cannot read bz2 from open file handle" at https://raw.github.com/hawkw/traverse/master/data/-home-w-weismanm_2014-02-06.csv.bz2
  </code></pre>
  
  <p>Anybody know what I'm doing wrong?</p>
  
  <p>Edit: I tried opening the file using <code>urllib2</code> like this, as @edchum suggested:</p>
  
  <pre><code>datafiles = {}
  
  for filename in csvData['Filename']:
  
      url = 'https://raw.github.com/hawkw/traverse/master/data/' + filename
  
      try:
          response = urllib2.urlopen(url)
      except HTTPError as e:
          print ("Caught HTTPError", e)
      else:
          try:
              datafiles[filename] = pandas.read_csv(response, compression='bz2')
              print (datafiles[filename])
          except Exception as e:
              print("Caught error \"{0}\" at {1}".format(e,url))
  </code></pre>
  
  <p>But it still didn't work, failing with the same error. As a side note, <code>pandas.read_csv()</code> says that it can open files from URLs in the docs.</p>