gpt4 book ai didi

google-colaboratory - 在Google可移植笔记本中找不到CSV文件错误

转载 作者:行者123 更新时间:2023-12-04 18:01:22 26 4
gpt4 key购买 nike

I am trying to load csv file stored in google drive to colab notebooks. When i try to load the file it is showing "File not found". What is the procedure to load files stored in google drive to colab notebooks??

最佳答案

要从Google云端硬盘访问文件,您需要使用PyDrive或Drive Rest API加载文件。

在访问文件之前运行以下代码

!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

# 1. Authenticate and create the PyDrive client.
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

# 2. Load a file by ID and create local file.
downloaded = drive.CreateFile({'id':'fileid'}) # replace fileid with Id of file you want to access
downloaded.GetContentFile('export.csv') # now you can use export.csv

关于google-colaboratory - 在Google可移植笔记本中找不到CSV文件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48323471/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com