MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to store data files in packages

  • To: mathgroup at
  • Subject: [mg103702] Re: How to store data files in packages
  • From: David Bailey <dave at>
  • Date: Sat, 3 Oct 2009 09:01:31 -0400 (EDT)
  • References: <ha213g$n9i$>

Karsten W. 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.
This delivers the name of the package .m file, but it is obviously 


You need to execute this as the package is being read in, and assign the 
result to a private variable.

I use it, then test the result to determine if it worked, and otherwise 
do a messy search for the file in the possible directories.

Once you have the full path name of the .m file, you can easily compute 
the location of your resources.

This is definitely something that is missing from Mathematica, that 
would be trivial for WRI to add!

David Bailey

  • Prev by Date: Re: Incorrect symbolic improper integral
  • Next by Date: Re: Making raw HTML appear in a notebook exported to HTML
  • Previous by thread: Re: How to store data files in packages
  • Next by thread: PrintTemporary from inside DynamicModule