Ask Your Question
3

How to use a worksheet content in another worksheet?

asked 2013-01-18 18:57:39 +0100

anatematic gravatar image

I have a long worksheet, whose first part defines functions and the second part use them. I would like to split it in two worksheet, keeping the definition in the first one and loading all of them in the second one where they are used. Is it possible to do it?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-01-19 18:12:25 +0100

ndomes gravatar image

You can use the data menu. Create a file, for example 'definitions.sage', move your functions into this file and load it in your worksheet:

load(DATA+'definitions.sage')

edit flag offensive delete link more
1

answered 2013-01-20 05:08:06 +0100

ndomes gravatar image

Do you want to use the definitions in different worksheets?

Unfortunately there is no way to store a data file in the users home directory (or I don't know about) unless you have direct access to the server. (I tried data file names like '../../test.sage', but it didn't work, the file appears in the data sub-folder of the current worksheet.

Suppose you have stored a data file 'test.sage' in a worksheet with ID 100, you can access this file in another worksheet with

load(DATA+'../../100/data/test.sage')

If you run your own server you can store a file (for example 'impressum.sage') in your sage notebook home directory. Access from any of your worksheets can be done like this:

MYHOME = os.path.normpath(DATA+'/../..')+os.sep
load(MYHOME+'impressum.sage')

May be it can be done more straightforward?

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2013-01-18 18:57:39 +0100

Seen: 1,017 times

Last updated: Jan 20 '13