将私人数据导入谷歌协作笔记本的常用方法是什么?是否可以导入一个非公开的谷歌表?不能从系统文件中读取。介绍性文档链接到使用BigQuery的指南,但这似乎有点…多。


当前回答

已解决,请在这里找到详细信息,并使用下面的功能: https://stackoverflow.com/questions/47212852/how-to-import-and-read-a-shelve-or-numpy-file-in-google-colaboratory/49467113#49467113

from google.colab import files
import zipfile, io, os

    def read_dir_file(case_f):
        # author: yasser mustafa, 21 March 2018  
        # case_f = 0 for uploading one File and case_f = 1 for uploading one Zipped Directory
        uploaded = files.upload()    # to upload a Full Directory, please Zip it first (use WinZip)
        for fn in uploaded.keys():
            name = fn  #.encode('utf-8')
            #print('\nfile after encode', name)
            #name = io.BytesIO(uploaded[name])
        if case_f == 0:    # case of uploading 'One File only'
            print('\n file name: ', name)
            return name
        else:   # case of uploading a directory and its subdirectories and files
            zfile = zipfile.ZipFile(name, 'r')   # unzip the directory 
            zfile.extractall()
            for d in zfile.namelist():   # d = directory
                print('\n main directory name: ', d)
                return d
    print('Done!')

其他回答

对于那些像我一样从谷歌搜索关键字“上传文件colab”的人:

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

在谷歌colabs 如果这是你第一次

from google.colab import drive
drive.mount('/content/drive')

运行这些代码并遍历输出链接 然后穿过传送带到达箱子

复制时,你可以按照下面的方法复制, 转到文件右键单击并复制路径 ***不要忘记删除" /content "

f = open("drive/My Drive/RES/dimeric_force_field/Test/python_read/cropped.pdb", "r")

您可以通过运行以下命令挂载到谷歌驱动器 从谷歌。Colab导入驱动器 drive.mount(/内容/驱动器) 训练后复制数据从gdrive到colab根文件夹。

cp -r '/content/drive/My drive/ Project_data' '/content'

其中第一个路径是gdrive路径,第二个是colab根文件夹。

这种方法对于大数据的训练速度更快。

快速,简单地从Dropbox导入:

!pip install dropbox
import dropbox
access_token = 'YOUR_ACCESS_TOKEN_HERE' # https://www.dropbox.com/developers/apps
dbx = dropbox.Dropbox(access_token)

# response = dbx.files_list_folder("")

metadata, res = dbx.files_download('/dataframe.pickle2')

with open('dataframe.pickle2', "wb") as f:
  f.write(res.content)

上传数据/导入数据到谷歌colab GUI方式的最佳和简单的方法是点击左边的第3个选项文件菜单图标,在那里你会得到上传浏览器文件,因为你在windows操作系统。检查下面的图像更好地容易理解。点击下面两个选项后,你会很容易地得到上传窗口框。工作。

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