title: How to load csv.gpg file from GCS to Bigquery suing airflow or python
body: <p>we have a requirement to decrypt and load .gpg file from GCS to Bigquery in airflow. Is there any easiest quick way to decrypt and load at same time from gcs to BQ?</p>
  <p>The process I have used :</p>
  <ol>
  <li><p>download the file to local server</p>
  </li>
  <li><p>decrypt and upload the same to gcs</p>
  </li>
  <li><p>load from gcs to BQ</p>
  <pre><code> import pgpy
   import os
   from google.cloud import secretmanager
   from google.cloud import storage
   from io import BytesIO
  
   def upload_to_bucket(blob_name, output, bucket_name):
       storage_client = storage.Client()
       bucket = storage_client.get_bucket(bucket_name)
       blob = bucket.blob(blob_name)
       blob.upload_from_string(data=output.read())
       output.close()
       return blob.public_url
  
   def get_secret(project, key_id, version):
  
       client = secretmanager.SecretManagerServiceClient()
       name=f&quot;projects/{project}/secrets/{key_id}/versions/{version}&quot;
       response = client.access_secret_version(request={&quot;name&quot;: name})
       return response.payload.data.decode('ascii')
  
   fetch_key = get_secret('project', 'secret_key', version)
   key, _ = pgpy.PGPKey.from_blob(fetch_key) 
   storage_client = storage.Client()
   bucket = storage_client.get_bucket('bucket_name')
  
   blob = bucket.blob('test.csv.gpg')
   local_path=os.path.join(os.getcwd(),'teest.csv.gpg')
   blob.download_to_filename(os.path.join(os.getcwd(),'test.csv.gpg'))
   print(local_path)
   msg_encrypted = pgpy.PGPMessage.from_file(local_path)
   msg_plaintext = BytesIO((key.decrypt(msg_encrypted).message))
   print(msg_plaintext)
   g=upload_to_bucket('test.csv', msg_plaintext, 'buckeet')
   print(g)
  </code></pre>
  <p>os.remove(local_path)</p>
  </li>
  </ol>
  <p>Do we have any option to read directly from gcs and load to BQ?</p>