Google Colab #1

Google Colabでファイルの入出力について調べ、

以下の記事を試してみた。

 

blog.amedama.jp 

データセットは、以下のように読み込む。

from google.colab import files
uploaded = files.upload()

 

Google Driveへの出力は、以下の通り。

!pip install -U -q PyDrive

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials

auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

 

upload_file = drive.CreateFile()
upload_file.SetContentFile("report.html")
upload_file.Upload()

 

 参考にしたサイト

qiita.com