Google Sheets 到 Google Cloud Storage 傳輸 Operators¶
Google 提供了一項服務 Google Cloud Storage。該服務用於儲存來自各種應用程式的大資料。
藉助 Google Sheets,每個人都可以同時在同一個電子表格中協作。使用公式、函式和格式設定選項,可以節省時間並簡化常見的電子表格任務。
先決條件任務¶
要使用這些 Operators,您必須完成以下幾項操作
使用 Cloud Console 選擇或建立一個 Cloud Platform 專案。
為您的專案啟用結算功能,具體方法請參閱 Google Cloud 文件。
啟用 API,具體方法請參閱 Cloud Console 文件。
透過 pip 安裝 API 庫。
pip install 'apache-airflow[google]'有關 安裝 的詳細資訊。
將資料從 Google Sheets 上傳到 GCS¶
要將資料從 Google Spreadsheet 上傳到 Google Cloud Storage,可以使用 GoogleSheetsToGCSOperator。
tests/system/google/cloud/gcs/example_sheets_to_gcs.py
upload_sheet_to_gcs = GoogleSheetsToGCSOperator(
task_id="upload_sheet_to_gcs",
destination_bucket=BUCKET_NAME,
spreadsheet_id="{{ task_instance.xcom_pull(task_ids='create_spreadsheet', key='spreadsheet_id') }}",
gcp_conn_id=CONNECTION_ID,
)
您可以將 Jinja 模板 與 spreadsheet_id, destination_bucket, destination_path, sheet_filter, impersonation_chain 一起使用。