data=Import["largedatafile.csv"];
ListPlot[data]
I'd like to have "data" saved in the notebook, so that when I open it,
I can replot the data. My current solution is to copy and paste the
data manually into a separate mathematica cell (ie, data={1,2,3...}),
but that causes the front-end to freeze when largedatafile.csv is too
large.
Yaroslav
Put the data file into the same directory where the notebook is, and use
NotebookDirectory[] to find its location. This way the data file and
notebook can be moved around freely.
--
Szabolcs
Assuming you're using version 6, you could get a compressed form by doing...
Compress[data]
...then modify the output cell by putting the caret at the beginning and typing
data=Uncompress@
which will convert the Output cell into an Input cell you can evaluate in the
future. It's not quite as fast and convenient as DumpSave, of course, but if
you really insist on keeping the data in the notebook, it'll work.
Now it turns out that the graphic resulting from the ListPlot[] has all of the
data you passed into it, in the aforementioned compressed form embedded in it.
You can easily send that graphic back to the kernel to pick apart the expression
(which is automatically uncompressed...no Uncompress[] command is required) and
pull the data back out of it, without requiring the additional copy of the data
my above procedure would create.
Assuming you haven't used any exotic options to ListPlot (most noticeably,
PlotMarkers, which will considerably change how the data are represented in the
graphic), then typing the following input around the graphic (i.e. place the
caret before the graphic and type, then after, and type, or using copy/paste to
insert a copy of the graphic into a new Input cell) will get what you want...
Cases[ <graphic> , Point[{x__}]:>x, 2]
Sincerely,
John Fultz
jfu...@wolfram.com
User Interface Group
Wolfram Research, Inc.
> > I'd like to have "data" saved in the notebook, so that when I open it,
> > I can replot the data. My current solution is to copy and paste the
> > data manually into a separate mathematica cell (ie, data={1,2,3...}),
> > but that causes the front-end to freeze when largedatafile.csv is too
> > large.
> >
> > Yaroslav
>
> Assuming you're using version 6, you could get a compressed form by doing...
>
> Compress[data]
>
> ...then modify the output cell by putting the caret at the beginning and
> typing
>
> data=Uncompress@
>
> which will convert the Output cell into an Input cell you can evaluate in the
> future. It's not quite as fast and convenient as DumpSave, of course, but if
> you really insist on keeping the data in the notebook, it'll work.
John,
Thanks very much. This is one of those very useful tricks that might be
difficult for an ordinary user to develop by himself, but can be
understood and used once you've seen it.
As an extension to it: Suppose the data in question is not necessarily
a Plot, maybe just a List; said List is the Output cell created by
executing an Input cell; and each time one executes said Input cell one
wants to save the new result **and not erase any of the old ones** that
may still be sitting there -- except of course one doesn't want to go
too far in doing this if the List is large, and one will want to delete
selected older Saved Lists from time to time.
I think I can actually figure out a procedure that can do this task by
myself (maybe add a random name or date to the List name each time you
Save one?). But of course if someone more skilled than me wanted to lay
out a template for doing this, I'd be delighted to use it instead.
On Oct 7, 9:01 pm, AES <sieg...@stanford.edu> wrote:
> In article <fea47j$i2...@smc.vnet.net>, John Fultz <jfu...@wolfram.com>
With[{x = Compress[data]},
Interpretation["<<Compressed Data>>", Uncompress[x]]]
Note...it doesn't matter what the first argument of Interpretation is, as this
merely defines the appearance.
Sincerely,
John Fultz
jfu...@wolfram.com
User Interface Group
Wolfram Research, Inc.