google-colaboratory - 无法读取 google colaboratory 中的文件

标签 google-colaboratory

无法读取 google colaboratory 中的文件。
我在同一目录中有 .ipynb 文件和 .csv 文件,但是当我尝试运行时:

train = pd.read_csv("train.csv") 

我得到:
FileNotFoundError: File b'train.csv' does not exist

enter image description here

最佳答案

我希望您在打开 train 之前已经运行了此代码文件。

第一部分
# Install a Drive FUSE wrapper. # https://github.com/astrada/google-drive-ocamlfuse !apt-get install -y -qq software-properties-common python-software-properties module-init-tools !add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null !apt-get update -qq 2>&1 > /dev/null !apt-get -y install -qq google-drive-ocamlfuse fuse
第二部分
# Generate auth tokens for Colabfrom google.colab import auth auth.authenticate_user()
第三部分
# Generate creds for the Drive FUSE library.from oauth2client.client import GoogleCredentials creds = GoogleCredentials.get_application_default() import getpass !google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL vcode = getpass.getpass() !echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}
第四部分
# Create a directory and mount Google Drive using that directory.!mkdir -p drive !google-drive-ocamlfuse drive
第五部分
print ('Files in Drive:') !ls drive/
执行上述代码后,只需打开您的 train文件在 google-colaboratorytrain = pd.read_csv('drive/...{folder_name}.../train.csv, encoding='utf8')
我希望这有帮助!

关于google-colaboratory - 无法读取 google colaboratory 中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48967757/

相关文章:

python - 有没有办法将 Google Colab 代码转换为网络服务或休息 API

python - 如何在Google Colaboratory中旋转3D散点图?

dataset - 如何将数据集下载到 Colab 中?遇到问题,它说 "401 - Unauthorized"?

python - 在Google CoLab Notebook中,如何在不进行两次身份验证的情况下从公共(public)Google云端硬盘和我的个人硬盘读取数据?

python - 是否可以使用 Colboratory 安装tensorflow.serving

python - Google Colab - Spotipy 没有将我重定向到指定的redirect_uri

azure - Ms Azure 与 Google Colab BERT 训练性能的令人惊讶的结果,不知道如何解释

ubuntu - 如何在 Google Colab 上安装 gmpy2?

tensorflow - 如何在 Google Colab 中高效使用 GPU RAM?

google-colaboratory - ValueError:形状(无,1)和(无,5)在keras中不兼容