> I built a worksheet with several cells in the notebook, and then > wanted to try to run it on a remote computer using the command line > interface. But I could not find a convincing way to export the > worksheet to a simple text file that I could import directly to sage, > i.e. a "something.sage" file.
> In the end, I had to copy and paste each cell separately into a text > file on the remote machine, which I then imported with "load > something.sage" But this is clearly not a reasonable solution for a > long worksheet. > I tried the "Text" option in the worksheet, but that produced output > which I could not just copy straight into the sage command line, or > import with "load". If Sage has an easy, automatic way of doing this, I'm not aware of it. However, there's a couple ways to accomplish what you want to do without doing a bunch of repetitive actions (for example, manually copying out each the text cell). Unfortunately, both of my suggestions require a bit of work: (1) Open the worksheet through the notebook interface, then click on the "Text" tab. Copy the text there, then write a little script to strip out every line that doesn't begin with "sage: ". The lines that have "sage: " prepended are lines in the input cells (assuming you didn't type "sage: " somewhere in the worksheet itself). Strip out the "sage: " text. (2) You could tinker around with Notebook, Worksheet, and Cell objects in Sage (using a script, command-line, or notebook interface). In summary, you could create a Notebook object; get the desired Worksheet object using one of the methods of the Notebook object; get a list of Cell objects from the Worksheet; then pull out the input text from each Cell object. The documentation for these objects are: http://www.sagemath.org/doc/reference/sagenb/notebook/notebook.html http://www.sagemath.org/doc/reference/sagenb/notebook/worksheet.html http://www.sagemath.org/doc/reference/sagenb/notebook/cell.html Again, I'm (obviously) not aware of a cleaner way to just pull out the input text from a worksheet, and these two suggestions are just the work-arounds I could think of. As a side-note, the inverse process (converting from plain-text commands to a sage worksheet) is easy; just upload it through the notebook interface. -- Tianwei -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
