想尝试 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
这是我找到的其他一些链接..