ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 19 Feb 2014 16:00:24 +0100Save and retrieving my datahttps://ask.sagemath.org/question/11039/save-and-retrieving-my-data/I often compute things that take a lot of time. When I stop working, I have to turn off my laptop. When I resume my work later, I'd like to be able to retrieve the previous data, computations, etc. For instance, I have computed a big list and stored it to the variable `x`. I would like to be able to save my data including the contents of this variable, then when I resume my work, I'd like to be able to have `x` back.
I tried to save my data to a file `mydata.dat` via the *Data -->Upload or create file* menu. Then, I quit sage, ran it again, and tried to link the data file back via the same menu. I got the following:
> The data filename already exists in other worksheet Delete the file in the other worksheet before creating a link.
I don't really understand what that means. Then, I tried all of the following:
DATA+'mydata.dat'
open(DATA+'mydata.dat')
DATA=DATA+'mydata.dat'
but in any case, if I type x, I get
NameError: name 'x' is not defined
Could somebody tell me how I should achieve what I'm trying?
Sat, 15 Feb 2014 17:36:12 +0100https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/Answer by calc314 for <p>I often compute things that take a lot of time. When I stop working, I have to turn off my laptop. When I resume my work later, I'd like to be able to retrieve the previous data, computations, etc. For instance, I have computed a big list and stored it to the variable <code>x</code>. I would like to be able to save my data including the contents of this variable, then when I resume my work, I'd like to be able to have <code>x</code> back. </p>
<p>I tried to save my data to a file <code>mydata.dat</code> via the <em>Data -->Upload or create file</em> menu. Then, I quit sage, ran it again, and tried to link the data file back via the same menu. I got the following:</p>
<blockquote>
<p>The data filename already exists in other worksheet Delete the file in the other worksheet before creating a link. </p>
</blockquote>
<p>I don't really understand what that means. Then, I tried all of the following:</p>
<pre><code>DATA+'mydata.dat'
open(DATA+'mydata.dat')
DATA=DATA+'mydata.dat'
</code></pre>
<p>but in any case, if I type x, I get</p>
<pre><code>NameError: name 'x' is not defined
</code></pre>
<p>Could somebody tell me how I should achieve what I'm trying?</p>
https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?answer=16047#post-id-16047You can write the data to a csv file in the DATA directory. I do this regularly with my applications. You can find some code for this at:
http://ask.sagemath.org/question/2154/how-to-output-data-to-a-file
Sun, 16 Feb 2014 20:24:17 +0100https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?answer=16047#post-id-16047Answer by Jeroen Demeyer for <p>I often compute things that take a lot of time. When I stop working, I have to turn off my laptop. When I resume my work later, I'd like to be able to retrieve the previous data, computations, etc. For instance, I have computed a big list and stored it to the variable <code>x</code>. I would like to be able to save my data including the contents of this variable, then when I resume my work, I'd like to be able to have <code>x</code> back. </p>
<p>I tried to save my data to a file <code>mydata.dat</code> via the <em>Data -->Upload or create file</em> menu. Then, I quit sage, ran it again, and tried to link the data file back via the same menu. I got the following:</p>
<blockquote>
<p>The data filename already exists in other worksheet Delete the file in the other worksheet before creating a link. </p>
</blockquote>
<p>I don't really understand what that means. Then, I tried all of the following:</p>
<pre><code>DATA+'mydata.dat'
open(DATA+'mydata.dat')
DATA=DATA+'mydata.dat'
</code></pre>
<p>but in any case, if I type x, I get</p>
<pre><code>NameError: name 'x' is not defined
</code></pre>
<p>Could somebody tell me how I should achieve what I'm trying?</p>
https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?answer=15980#post-id-15980See the help for `save??`, also at <http://www.sagemath.org/doc/reference/structure/sage/structure/sage_object.html#sage.structure.sage_object.save>Sun, 16 Feb 2014 04:53:48 +0100https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?answer=15980#post-id-15980Comment by kcrisman for <p>See the help for <code>save??</code>, also at <a href="http://www.sagemath.org/doc/reference/structure/sage/structure/sage_object.html#sage.structure.sage_object.save">http://www.sagemath.org/doc/reference/structure/sage/structure/sage_object.html#sage.structure.sage_object.save</a></p>
https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?comment=16249#post-id-16249In particular, note `load`.Sun, 16 Feb 2014 20:25:23 +0100https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?comment=16249#post-id-16249Comment by geo909 for <p>See the help for <code>save??</code>, also at <a href="http://www.sagemath.org/doc/reference/structure/sage/structure/sage_object.html#sage.structure.sage_object.save">http://www.sagemath.org/doc/reference/structure/sage/structure/sage_object.html#sage.structure.sage_object.save</a></p>
https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?comment=16240#post-id-16240@kcrisman Thanks, but I have the same problem with that; I'd have to save each variable seperately, I may have 100 of them and would like to save the data for the whole worksheet lazily..Tue, 18 Feb 2014 18:56:31 +0100https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?comment=16240#post-id-16240Comment by geo909 for <p>See the help for <code>save??</code>, also at <a href="http://www.sagemath.org/doc/reference/structure/sage/structure/sage_object.html#sage.structure.sage_object.save">http://www.sagemath.org/doc/reference/structure/sage/structure/sage_object.html#sage.structure.sage_object.save</a></p>
https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?comment=16252#post-id-16252Thanks, that's probably what I'd have to go with. However, I was wondering if there is a way to save all the data of a specific worksheet without having to explicitely save every variable to a file. I may have too many of them. Isn't that what the data files were supposed to do?Sun, 16 Feb 2014 12:59:16 +0100https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?comment=16252#post-id-16252Answer by kcrisman for <p>I often compute things that take a lot of time. When I stop working, I have to turn off my laptop. When I resume my work later, I'd like to be able to retrieve the previous data, computations, etc. For instance, I have computed a big list and stored it to the variable <code>x</code>. I would like to be able to save my data including the contents of this variable, then when I resume my work, I'd like to be able to have <code>x</code> back. </p>
<p>I tried to save my data to a file <code>mydata.dat</code> via the <em>Data -->Upload or create file</em> menu. Then, I quit sage, ran it again, and tried to link the data file back via the same menu. I got the following:</p>
<blockquote>
<p>The data filename already exists in other worksheet Delete the file in the other worksheet before creating a link. </p>
</blockquote>
<p>I don't really understand what that means. Then, I tried all of the following:</p>
<pre><code>DATA+'mydata.dat'
open(DATA+'mydata.dat')
DATA=DATA+'mydata.dat'
</code></pre>
<p>but in any case, if I type x, I get</p>
<pre><code>NameError: name 'x' is not defined
</code></pre>
<p>Could somebody tell me how I should achieve what I'm trying?</p>
https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?answer=16048#post-id-16048Can you use the `save_session` command?Sun, 16 Feb 2014 20:26:17 +0100https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?answer=16048#post-id-16048Comment by kcrisman for <p>Can you use the <code>save_session</code> command?</p>
https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?comment=16235#post-id-16235Awesome. In that event, don't forget to up vote this and/or accept it, so that others will know it's what you meant.Wed, 19 Feb 2014 16:00:24 +0100https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?comment=16235#post-id-16235Comment by geo909 for <p>Can you use the <code>save_session</code> command?</p>
https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?comment=16239#post-id-16239From a first look, it seems that this is probably what I was asking for in the first place.Tue, 18 Feb 2014 19:05:35 +0100https://ask.sagemath.org/question/11039/save-and-retrieving-my-data/?comment=16239#post-id-16239