title: using Google BigQuery through Python script
body: <p>I want to make some very easy tasks on BigQuery via a python script. I found <a href="https://github.com/tylertreat/BigQuery-Python" rel="nofollow">this package</a> which does not work well. Indeed, when I try this code:</p>
  
  <pre><code>from bigquery import get_client
  
  
  project_id = 'txxxxxxxxxxxxxxxxxx9'
  # Service account email address as listed in the Google Developers Console.
  service_account = '7xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com'
  # PKCS12 or PEM key provided by Google.
  key = '/home/fxxxxxxxxxxxx/Dropbox/access_keys/google_storage/xxxxxxxxxxxxxxxxxxxxx.pem'
  client = get_client(project_id, service_account=service_account, private_key_file=key, readonly=True)
  # Submit an async query.
  results = client.get_table_schema('newdataset', 'newtable2')
  
  print('results')
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>/home/xxxxxx/anaconda3/envs/snakes/bin/python2.7 /home/xxxxxx/Dropbox/Prog/bigQuery_daily_import/src/main.py
  Traceback (most recent call last):
    File "/home/xxxxxx/Dropbox/Prog/bigQuery_daily_import/src/main.py", line 9, in &lt;module&gt;
      client = get_client(project_id, service_account=service_account, private_key_file=key, readonly=True)
    File "/home/xxxxxx/anaconda3/envs/snakes/lib/python2.7/site-packages/bigquery/client.py", line 83, in get_client
      readonly=readonly)
    File "/home/xxxxxx/anaconda3/envs/snakes/lib/python2.7/site-packages/bigquery/client.py", line 101, in _get_bq_service
      service = build('bigquery', 'v2', http=http)
    File "/home/xxxxxx/anaconda3/envs/snakes/lib/python2.7/site-packages/oauth2client/util.py", line 142, in positional_wrapper
      return wrapped(*args, **kwargs)
    File "/home/xxxxxx/anaconda3/envs/snakes/lib/python2.7/site-packages/googleapiclient/discovery.py", line 196, in build
      cache)
    File "/home/xxxxxx/anaconda3/envs/snakes/lib/python2.7/site-packages/googleapiclient/discovery.py", line 242, in _retrieve_discovery_doc
      resp, content = http.request(actual_url)
    File "/home/xxxxxx/anaconda3/envs/snakes/lib/python2.7/site-packages/oauth2client/client.py", line 565, in new_request
      self._refresh(request_orig)
    File "/home/xxxxxx/anaconda3/envs/snakes/lib/python2.7/site-packages/oauth2client/client.py", line 835, in _refresh
      self._do_refresh_request(http_request)
    File "/home/xxxxxx/anaconda3/envs/snakes/lib/python2.7/site-packages/oauth2client/client.py", line 862, in _do_refresh_request
      body = self._generate_refresh_request_body()
    File "/home/xxxxxx/anaconda3/envs/snakes/lib/python2.7/site-packages/oauth2client/client.py", line 1541, in _generate_refresh_request_body
      assertion = self._generate_assertion()
    File "/home/xxxxxx/anaconda3/envs/snakes/lib/python2.7/site-packages/oauth2client/client.py", line 1670, in _generate_assertion
      private_key, self.private_key_password), payload)
    File "/home/xxxxxx/anaconda3/envs/snakes/lib/python2.7/site-packages/oauth2client/_pycrypto_crypt.py", line 121, in from_string
      pkey = RSA.importKey(parsed_pem_key)
    File "/home/xxxxxx/anaconda3/envs/snakes/lib/python2.7/site-packages/Crypto/PublicKey/RSA.py", line 665, in importKey
      return self._importKeyDER(der)
    File "/home/xxxxxx/anaconda3/envs/snakes/lib/python2.7/site-packages/Crypto/PublicKey/RSA.py", line 588, in _importKeyDER
      raise ValueError("RSA key format is not supported")
  ValueError: RSA key format is not supported
  
  Process finished with exit code 1
  </code></pre>
  
  <p>My question: is there a tutorial in python which shows how to communicate easily with BigQuery: importing a dataset from google storage or S3, querying something, exporting the result to google storage.</p>