From: Karsten W. on
Hello,

my packages uses some data files. Currently, I store them in a
subdirectory "resources" below the package directory and access the
data via

ToFileName[{$UserBaseDirectory, "Applications", myPackage,
"resources"}, myDataFileName];

I wonder if this is a portable way. I am afraid it is not, since the
package may be installed under $BaseDirectory as well. And then there
is this directory at the same level as "Applications" named
"ApplicationData"

What is the recommended way to store my data files?

Any hint appreciated,

kind regards,
Karsten.

From: David Annetts on
Hi Karsten,

> my packages uses some data files. Currently, I store them in
> a subdirectory "resources" below the package directory and
> access the data via
>
> ToFileName[{$UserBaseDirectory, "Applications", myPackage,
> "resources"}, myDataFileName];

I used to do this with filter coefficients. There were only a few hundred
of them, and it was easier at the time to cut them from an F77 data block
and insert them into a file.

> I wonder if this is a portable way. I am afraid it is not,
> since the package may be installed under $BaseDirectory as
> well. And then there is this directory at the same level as
> "Applications" named "ApplicationData"
>
> What is the recommended way to store my data files?

I don't know whether it's recommended or not, but currently, I've got the
coefficients defined in the package's initialisation. The disadvantage is
that function readability goes way down, but upside is that I no longer need
to worry about reading multiple files when a function is called.

I would store them in the package rather than read them with the package.

But your mileage may vary,

D.



From: Vince on
On Oct 1, 6:42 am, "Karsten W." <karsten.g.wein...(a)googlemail.com>
wrote:
> Hello,
>
> my packages uses some data files. Currently, I store them in a
> subdirectory "resources" below the package directory and access the
> data via
>
> ToFileName[{$UserBaseDirectory, "Applications", myPackage,
> "resources"}, myDataFileName];
>
> I wonder if this is a portable way. I am afraid it is not, since the
> package may be installed under $BaseDirectory as well. And then there
> is this directory at the same level as "Applications" named
> "ApplicationData"
>
> What is the recommended way to store my data files?
>
> Any hint appreciated,
>
> kind regards,
> Karsten.

I think if you store the data in a relative subdirectory (say,
"Data"), and added the following to your package, you'd always be able
to find your data through "dataFiles".

dataFiles = FileNameJoin@{DirectoryName(a)FindFile@$Input, "Data"};

And I think this scales well. Consider multiple packages which all
reside in $UserBaseDirectory/Applications, and not a subdir thereof.
Those packages would share the "Data" directory. This could be
construed as a strength.


Vince Virgilio

From: David Park on
That is a very interesting question!

Currently WRI uses paclets to document packages through Workbench/DocuTools.
They also use paclets to serve up data but don't give us much information on
how to do that. It is possible to write an application that not only has a
documented package but also has folders of extra notebooks, say book
chapters - all within the application paclet and all linked and accessible.

I don't see why a user/developer couldn't also include data paclets in the
same application. WRI just has to show us how to do it and how to access the
data.

And I also don't see why a user shouldn't be able to construct a master list
of references as a data paclet and perhaps keep it in a separate
application.

The Workbench/DocuTools/Application/Paclet facility will, I believe, be a
powerful medium for organizing and preserving all kinds of serious work
within Mathematica.

One solution to your question would be to build the data into the package
itself, but it seems reasonable that a user should be able to maintain data
as a separate component of an application paclet.


David Park
djmpark(a)comcast.net
http://home.comcast.net/~djmpark/



From: Karsten W. [mailto:karsten.g.weinert(a)googlemail.com]


Hello,

my packages uses some data files. Currently, I store them in a
subdirectory "resources" below the package directory and access the
data via

ToFileName[{$UserBaseDirectory, "Applications", myPackage,
"resources"}, myDataFileName];

I wonder if this is a portable way. I am afraid it is not, since the
package may be installed under $BaseDirectory as well. And then there
is this directory at the same level as "Applications" named
"ApplicationData"

What is the recommended way to store my data files?

Any hint appreciated,

kind regards,
Karsten.



From: Yves Klett on
Hi,

you could store the data in the notebook itself. You can Compress[] any
expression into a string (compression rate naturally depending on the
data, but quite good in my experience), store that string in the target
notebook or package and Uncompress[] during evaluation (if there is
enough memory in case of large data sets).

The compression can be quite slow for large expression, but
uncompressing works quickly.

Regards,
Yves


Karsten W. schrieb:
> Hello,
>
> my packages uses some data files. Currently, I store them in a
> subdirectory "resources" below the package directory and access the
> data via
>
> ToFileName[{$UserBaseDirectory, "Applications", myPackage,
> "resources"}, myDataFileName];
>
> I wonder if this is a portable way. I am afraid it is not, since the
> package may be installed under $BaseDirectory as well. And then there
> is this directory at the same level as "Applications" named
> "ApplicationData"
>
> What is the recommended way to store my data files?
>
> Any hint appreciated,
>
> kind regards,
> Karsten.
>