11.07.2015 Views

webMathematica™ Wolfram - Wolfram Research

webMathematica™ Wolfram - Wolfram Research

webMathematica™ Wolfram - Wolfram Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

webMathematica User Guide 99Data Loading and ComputationMathematica contains a variety of data loading functions, available through the functionImport. This supports many formats such as comma and tab-delimited text data, as well asmore specialized formats for graphics, science, sound, and XML. In addition, binary data can beloaded using the function Experimental`BinaryImport. If you find that your particular data isnot well supported directly by Mathematica, it is possible that you may use a Java API to loadthe data, which was described in the previous section.In order to develop data loading technology, it is probably a good idea to work in interactiveMathematica so that you understand how the data loading functions work. When you have donethis, you can add data loading to your web applications. At this point you need to determine thesource for your data. The following sections discuss some of the possibilities.File I/OIf your data files are available to the file system of the computer on which your webMathematicaserver runs, they can be read with a command like Import. For this to work, the name andlocation of the data file must be specified. This can be done in several ways. One way involvesplacing the files into a directory and setting the full pathname of this directory. This suffersfrom the extreme disadvantage that if you change the name of the directory, you will have tomodify all your scripts that use this name. An improvement could be obtained by setting thename of the directory with an initialization parameter. This can be done in MSPConfiguration.xmlwith the parameter KernelInitializeCode as shown in the following.MyApplication`DataDirectory="C:\\Work\\Data"This assigns the Mathematica symbol MyApplication`DataDirectory to "C:\Work\Data". Notethe use of a full context name. This is necessary to prevent the symbol being cleared by thekernel cleaning mechanism. This can then be loaded in a webMathematica computation asshown in the following example.data = Import[ ToFileName[ MyApplication`DataDirectory, "file.dat"],"Table"];

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!