LoginSignup
Nurally
@Nurally

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

Google Cloud FunctionsでGoogle Drive内のcsv読み書き

解決したいこと

Google Cloud FunctionsでGoogle Drive内のcsvを読み書きしたい。
Google Cloud Scheduler上でのGoogle Cloud Functionsを起動して、
定期的にGoogle Drive内のcsvを読み込み・更新・保存し直したい。

Google Colabでは

from google.colab import drive; drive.mount('/content/drive')
df = pd.read_csv("/content/drive/My Drive/...csv",

を使用していたものの、Google Cloud Functionsで同じコードを使用すると

ModuleNotFoundError: No module named 'google.colab

が発生します。
Google Colabでの「from google.colab import drive」のような、
簡単にDriveファイルを読み込みできるモジュールは無いでしょうか。
それともDriveではなくGoogle Cloud Storageを使う必要があるのでしょうか。

補足

・Cloud Functions 第1世代, Python 3.12使用。

0

1Answer

環境が無いため試せませんが、
from googleapiclient.discovery import buildすることで、
Google Cloud FunctionsからGoogle Driveをアクセスできるようです。
以下の記事に「アクセス権追加」などが書かれています。
参考になりませんか?

0

Your answer might help someone💌