How to download file created in Colaboratory workspace?

后端 未结 7 1184
攒了一身酷
攒了一身酷 2020-12-07 23:55

I found many hints how to upload data into Colaboratory.

But now I want to do opposite -> I want to download .csv I\'ve created in Colaboratory workspace.

Ho

相关标签:
7条回答
  • 2020-12-08 00:49

    You need to add these two lines:

    from google.colab import files
    files.download('file.txt')
    

    If you are using firefox, then this won't work. For making this work:

    1. from google.colab import files
    2. In next cell, print anything, like print('foo').
    3. After it has printed, erase the print line and replace it with: files.download('file.txt')

    Now, it will download. This is a hacky solution told by me colleague. I don't know why it works! If you know why, please comment it.

    There is a more cleaner and easier way to do this which works in both firefox and chrome.

    Click on > icon. Click on files. It will display all the files and folders in your notebook. Left click on the file you want to download, choose download and you are good to go. This procedure can also be applied to upload file/folder. For uploading folder, you would have to zip it first though.

    0 讨论(0)
提交回复
热议问题