0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Google ColabでGoogle Drive内のCSVファイルのパスを確認する方法

Posted at

Google ColabでGoogle Drive内のCSVファイルのパスを確認する方法は以下の通りです:

  1. まず、Google Driveをマウントします。以下のコードを実行してください:
from google.colab import drive
drive.mount('/content/drive')
  1. 次に、左側のパネルで「ファイル」タブをクリックします。これにより、ファイルエクスプローラが表示されます。

  2. 「drive」→「My Drive」を開き、目的のCSVファイルが保存されているフォルダまで移動します。

  3. ファイルを右クリックし、「パスをコピー」を選択します。これにより、ファイルのパスがクリップボードにコピーされます。

  4. コピーしたパスを、Pythonの文字列としてコードセルに貼り付けます。例えば:

file_path = '/content/drive/My Drive/folder/myfile.csv'

以上の手順で、Google Drive内のCSVファイルのパスを取得し、それをGoogle Colabで使用することができます¹³。このパスは、pandasのread_csv()関数などで使用できます。ただし、Google Driveのファイルはセッションが終了するとアクセスできなくなるため、毎回パスを取得する必要があります。また、Googleアカウントへのアクセスを許可する必要がありますので、指示に従ってください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?