将本地数据文件加载到Colaboratory [英] Load local data files to Colaboratory

查看:181
本文介绍了将本地数据文件加载到Colaboratory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道是否可以将本地数据文件(例如Google驱动器上的.xlsx或.csv文件)加载到Colaboratory中?

I just wondering that is it possible to load local data files(like .xlsx or .csv files that on my google drive) into Colaboratory?

推荐答案

由于乍一看没有地方指定文件路径,我对加载本地文件的示例有点困惑.您所需要做的就是复制并粘贴食谱可以弄清楚这一点,但要明确:

I was a bit confused by the example for loading local files on first glance as there was no place to specify a file path. All you need to do is copy and paste the recipe to figure this out, but to be clear:

from google.colab import files
uploaded = files.upload()

将打开一个上传对话框,您可以在其中浏览并选择要上传的本地文件.

will open an upload dialogue window where you can browse and select your local files for upload.

然后

for fn in uploaded.keys():
  print('User uploaded file "{name}" with length {length} bytes'.format(
      name=fn, length=len(uploaded[fn])))

将向您显示访问刚刚上传的内容的密钥.

will show you the keys to access what you just uploaded.

编辑以进一步说明:词典uploaded将具有所选文件名的键-因此,例如,如果您选择文件my_test.txt,则可以使用uploaded['my_test.txt']访问该文件.

Edit for additional clarification: The dictionary uploaded will have keys of the selected filenames - so if for example you select a file my_test.txt, then you would access that file using uploaded['my_test.txt'].

这篇关于将本地数据文件加载到Colaboratory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆