【发布时间】:2018-07-04 08:28:19
【问题描述】:
想试用 python,而 google colaboratory似乎是最简单的选择。我的 google 驱动器中有一些文件,想将它们上传到 google colaboratory。 所以这是我正在使用的代码:
!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. Create & upload a file text file.
uploaded = drive.CreateFile({'xyz.csv': 'C:/Users/abc/Google Drive/def/xyz.csv'})
uploaded.Upload()
print('Uploaded file with title {}'.format(uploaded.get('title')))
import pandas as pd
xyz = pd.read_csv('Untitled.csv')
基本上,对于用户“abc”,我想从文件夹“def”上传文件 xyz.csv。 我可以上传文件,但是当我询问标题时,它说标题是“无标题”。 当我要求上传文件的 ID 时,它每次都会更改,所以我不能使用 ID。
如何读取文件???并设置一个合适的文件名???
xyz = pd.read_csv('Untitled.csv') doesnt work
xyz = pd.read_csv('Untitled') doesnt work
xyz = pd.read_csv('xyz.csv') doesnt work
这是我找到的其他一些链接..
How to import and read a shelve or Numpy file in Google Colaboratory?
【问题讨论】:
-
@Bob Smith..你能帮帮我吗
标签: python google-api google-drive-api google-api-python-client google-colaboratory