0

I am not sure why I can see the first 5 lines in the uploaded file in Jupyter notebook even though the file successfully uploads:

import io
from IPython.display import display
import fileupload

def _upload():

    _upload_widget = fileupload.FileUploadWidget()

    def _cb(change):
        decoded = io.StringIO(change['owner'].data.decode('utf-8'))
        filename = change['owner'].filename
        print('Uploaded `{}` ({:.2f} kB)'.format(
            filename, len(decoded.read()) / 2 **10))

    _upload_widget.observe(_cb, names='data')
    display(_upload_widget)

uploaded_file = _upload()
Uploaded `plot.R` (3.00 kB)
%%bash
pwd
head -5 uploaded_file
head -5 "/home/jalal/plot.R"
head -5 plot.R
%%bash

pwd

head -5 uploaded_file

head -5 "/home/jalal/plot.R"

head -5 plot.R

/home/jalal

head: cannot open ‘uploaded_file’ for reading: No such file or directory
head: cannot open ‘/home/jalal/plot.R’ for reading: No such file or directory
head: cannot open ‘plot.R’ for reading: No such file or directory

Also I tried this:

_upload

and then

head -5 filename

I get this error:

head: cannot open ‘filename’ for reading: No such file or directory
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408
  • Your code is a mish-mash of code and output, which you have presumably pasted from a notebook? It isn't really obvious what you are asking, sorry – holdenweb Sep 14 '16 at 16:41
  • @holdenweb maybe this is better? http://stackoverflow.com/questions/39495994/uploading-files-using-browse-button-in-jupyter-and-using-saving-them – Mona Jalal Sep 14 '16 at 17:02
  • Not really, but thanks for trying. It isn't clear which code belongs in a cell together, or how you uploaded the Notebook. When you write "I can see the first 5 items in the uploaded file in Jupyter notebook" I'm not sure what you mean by "the first 5 items". – holdenweb Sep 14 '16 at 17:04
  • first 5 lines! that's what head does~! – Mona Jalal Sep 14 '16 at 17:04

0 Answers0