Google Cloud Storage to Google Sheets Transfer Operators¶
Google has a service Google Cloud Storage. This service is used to store large data from various applications.
With Google Sheets, everyone can work together in the same spreadsheet at the same time. Use formulas functions, and formatting options to save time and simplify common spreadsheet tasks.
Prerequisite Tasks¶
To use these operators, you must do a few things:
Select or create a Cloud Platform project using the Cloud Console.
Enable billing for your project, as described in the Google Cloud documentation.
Enable the API, as described in the Cloud Console documentation.
Install API libraries via pip.
pip install 'apache-airflow[google]'Detailed information is available for Installation.
Upload data from GCS to Google Sheets¶
To upload data from Google Cloud Storage to Google Spreadsheet you can use the
GCSToGoogleSheetsOperator
.
upload_gcs_to_sheet = GCSToGoogleSheetsOperator(
task_id="upload_gcs_to_sheet",
bucket_name=BUCKET_NAME,
object_name="{{ task_instance.xcom_pull('upload_sheet_to_gcs')[0] }}",
spreadsheet_id="{{ task_instance.xcom_pull(task_ids='create_spreadsheet', "
"key='spreadsheet_id') }}",
gcp_conn_id=CONNECTION_ID,
)
You can use Jinja templating with
spreadsheet_id
, bucket_name
, object_name
, spreadsheet_range
, impersonation_chain
.