问题描述
我只是想知道是否可以将本地数据文件(例如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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!