Sergei Wallace
Sergei Wallace

Reputation: 1169

IPython Jupyter: uploading folder

Can you upload entire folders in IPython Jupyter? If so, how? I know how to upload individual files, of course, but this can get tedious if there are a large number of files and/or subdirectories.

Upvotes: 41

Views: 103696

Answers (4)

Apurva Singh
Apurva Singh

Reputation: 4990

On Windows, open terminal in Jupyter. You will get a Windows Powershell! Command prompt will be PS. It will show the local folder name also. But if Jupyter is remote, then do this:- * Open Terminal as already mentioned above * Create a single zipped file out of all your folders/files * Drag and drop the zipped file into Jupyter.. it will get uploaded * Open Terminal * Use powershell commands to upload as explained in this powershell link. It will be something like this:-

Expand-Archive -LiteralPath <name of zipped file> -DestinationPath .

Upvotes: 1

Ivan
Ivan

Reputation: 769

Maybe it is easier to just use unix to just unzip the data.

Steps:

  1. Transform the folder into a .zip file in your computer.

  2. Upload the .zip file to jupyter home.

  3. In jupyter notebook run

! unzip ~/yourfolder.zip -d ~/

where

! tells the jupyter notebook that you are going to give code directly to unix, not python code

unzip is the unzip commmand

~/yourfolder.zip tells the command where your .zip folder is (at ~/ if you uploaded to the home folder)

-d ~/ tells the command where you want to put the unzipped folder (this assumes you want to put it in the home folder, but you can also put it in any other subfolder with -d ~/my_first_level_subfolder or -d ~/my_first_level_subfolder/my_second_level_subfolder, etc.)

  1. If you want to delete the original .zip folder, delete it manually at jupyter home or use

!rm ~/yourfolder.zip

Hope if helps somebody

Upvotes: 14

Joys
Joys

Reputation: 351

Put your folder into

C:\Users\'YOUR USER NAME'\

Upvotes: 2

Afshin Amiri
Afshin Amiri

Reputation: 3583

Convert it into a single Zip file and upload that. to unzip the folder use the code down bellow

import zipfile as zf
files = zf.ZipFile("ZippedFolder.zip", 'r')
files.extractall('directory to extract')
files.close()

However, sometimes you may need to download several files from notebook. There are several ways to do this but the easiest way is to zip a directory and download the zip file:

import shutil
shutil.make_archive(output_filename_dont_add_.zip, 'zip', directory_to_download)

Upvotes: 61

Related Questions