Ask Your Question
1

Can we read local file from Sagecell

asked 2017-10-27 09:01:43 -0500

Niyamabrata gravatar image

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

edit retag flag offensive close merge delete

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 ( 2017-10-27 11:37:47 -0500 )edit

Thank you...

Niyamabrata gravatar imageNiyamabrata ( 2017-10-27 12:17:30 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2017-10-28 05:18:53 -0500

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.

edit flag offensive delete link more

Comments

Thanks a lot...

Niyamabrata gravatar imageNiyamabrata ( 2017-10-28 05:48:51 -0500 )edit
0

answered 2018-03-05 04:47:53 -0500

fh gravatar image

Yes, you can:

with open("/path/filename", 'r') as fin:
    print fin.read()
edit flag offensive delete link more

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. ( 2018-03-05 10:12:12 -0500 )edit

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

fh gravatar imagefh ( 2018-03-08 09:06:46 -0500 )edit
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 ( 2018-03-10 19:50:24 -0500 )edit

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: 2017-10-27 09:01:43 -0500

Seen: 238 times

Last updated: Mar 05