Ask Your Question
1

Can we read local file from Sagecell

asked 2017-10-27 16:01:43 +0200

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 18:37:47 +0200 )edit

Thank you...

Niyamabrata gravatar imageNiyamabrata ( 2017-10-27 19:17:30 +0200 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-10-28 12:18:53 +0200

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 12:48:51 +0200 )edit
0

answered 2018-03-05 11:47:53 +0200

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 17:12:12 +0200 )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 16:06:46 +0200 )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-11 02:50:24 +0200 )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 16:01:43 +0200

Seen: 865 times

Last updated: Mar 05 '18