上传数据集始终在GoogleColab中失败,如下图所示

时间:2018-05-27 11:50:39

标签: python google-colaboratory

upload always fail...

上传数据集总是在GoogleColab中失败,这是一个150MB的数据集(csv文件)

1 个答案:

答案 0 :(得分:1)

我怀疑这是由于当地的网络条件造成的。

首先尝试将数据上传到Google云端硬盘,然后从那里访问它。

以下是有关如何执行该操作的代码段(查找完整示例here

# Download the file we just uploaded.
#
# Replace the assignment below with your file ID
# to download a different file.
#
# A file ID looks like: 1uBtlaggVyWshwcyP6kEI-y_W3P8D26sz
file_id = 'target_file_id'

import io
from googleapiclient.http import MediaIoBaseDownload

request = drive_service.files().get_media(fileId=file_id)
downloaded = io.BytesIO()
downloader = MediaIoBaseDownload(downloaded, request)
done = False
while done is False:
  # _ is a placeholder for a progress object that we ignore.
  # (Our file is small, so we skip reporting progress.)
  _, done = downloader.next_chunk()

downloaded.seek(0)
print('Downloaded file contents are: {}'.format(downloaded.read()))