Ask Your Question
1

Can we read local file from Sagecell

asked 7 years ago

Niyamabrata gravatar image

Can we read local file from Sagecell? I work with SageMathCell embedded on blog.

Preview: (hide)

Comments

Hmm, that is a good question. I'd assume not unless you can read from the internet - some Sage functions allow URLs in them. But it wouldn't have access to your file system.

kcrisman gravatar imagekcrisman ( 7 years ago )

Thank you...

Niyamabrata gravatar imageNiyamabrata ( 7 years ago )

2 Answers

Sort by » oldest newest most voted
1

answered 7 years ago

tmonteil gravatar image

No, you can not read a local file from Sagecell. Sagecell is like any webserver, imagine the security hole if an arbitrary webserver you connect to with a webbrowser could read any file on your hard disk ! If you want to let Sagecell access some file, you have to serve it publically, this works well, see the answer of your other question.

Preview: (hide)
link

Comments

Thanks a lot...

Niyamabrata gravatar imageNiyamabrata ( 7 years ago )
0

answered 7 years ago

fh gravatar image

Yes, you can:

with open("/path/filename", 'r') as fin:
    print fin.read()
Preview: (hide)
link

Comments

This is a way to read local files into a SageMath notebook on your own computer, but it won't work on SageMathCell: https://sagecell.sagemath.org/

j.c. gravatar imagej.c. ( 7 years ago )

I tried it on https://sagecell.sagemath.org/ and a reasonable output was produced for the file "/etc/hosts".

fh gravatar imagefh ( 7 years ago )
1

But that isn't local to YOUR computer, is it? Presumably whatever Google App Engine computer is running the cell server.

kcrisman gravatar imagekcrisman ( 7 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 7 years ago

Seen: 1,302 times

Last updated: Mar 05 '18