Download all files in a path on Jupyter notebook server

前端 未结 7 669
日久生厌
日久生厌 2021-01-29 18:46

As a user in a class that runs Jupyter notebooks for assignments, I have access to the assignments via the web interface. I assume the assignments are stored somewhere in my per

相关标签:
7条回答
  • 2021-01-29 19:20

    I am taking Prof. Andrew Ng's Deeplearning.ai program via Coursera. The curriculum uses Jupyter Notebooks online. Along with the notebooks are folders with large files. Here's what I used to successfully download all assignments with the associated files and folders to my local Windows 10 PC.

    Start with the following line of code as suggested in the post by Serzan Akhmetov above:

    !tar cvfz allfiles.tar.gz *
    

    This produces a tarball which, if small enough, can be downloaded from the Jupyter notebook itself and unzipped using 7-Zip. However, this course has individual files of size 100's of MB and folders with 100's of sample images. The resulting tarball is too large to download via browser.

    So add one more line of code to split files into manageable chunk sizes as follows:

    !split -b 50m allfiles.tar.gz allfiles.tar.gz.part.
    

    This will split the archive into multiple parts each of size 50 Mb (or your preferred size setting). Each part will have an extension like allfiles.tar.gz.part.xx. Download each part as before.

    The final task is to untar the multi-part archive. This is very simple with 7-Zip. Just select the first file in the series for extraction with 7-Zip. This is the file named allfiles.tar.gz.part.aa for the example used. It will pull all the necessary parts together as long as they are in the same folder.

    Hope this helps add to Serzan's excellent answer above.

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