MathGroup Archive 2000

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

Search the Archive

Re: data from mathematica to be saved in ascii format

  • To: mathgroup at
  • Subject: [mg25961] Re: [mg25926] data from mathematica to be saved in ascii format
  • From: Tomas Garza <tgarza01 at>
  • Date: Tue, 14 Nov 2000 03:46:54 -0500 (EST)
  • Sender: owner-wri-mathgroup at

OK, there is a standard program which I got years ago from Wolfram 
support, I guess, which takes data from Mathematica and stores them as 
Ascii text files which can then be read by Excel or some other such 
program (I presume you want to use your data outside Mathematica; 
otherwise there is no point in saving it with a specified format). The 
code is as follows:

WriteMatrix[filename_String, data_List] :=
 With[{myfile = OpenWrite[filename]},
  Scan[(WriteString[myfile, First[#]];
    Scan[WriteString[myfile, "\t", #] &, Rest[#]];
    WriteString[myfile, "\n"]) &, data];

Once you define this function WriteMatrix, you may use it as follows:

a = {{1, 2, 3}, {1, 4, 5}, {1, 6, 7}};

WriteMatrix["b", a]

This says: take list a and store it in Ascii form under the name "b". 
Once you execute this, you will find b in the directory you're working. 
Then you may read b from Excel, say, and then format in scientific form. 
This will do what you want.

Tomas Garza
Mexico City

"Nilanjan Mitra" <mitra at> wrote:

> It would be great if anyone could solve tis problem which I am facing. 
> hope it is very simple but I with my limited knowledge is not able to 
> through it.
> I want to save a 3*3 matrix in mathematica say 
> to the following format under a dat file.
> 1.0000000e+000  2.0000000e+000  3.0000000e+000
> 1.0000000e+000  4.0000000e+000  5.0000000e+000
> 1.0000000e+000  6.0000000e+000  7.0000000e+000
> I hope someone will volunter to help me out.

  • Prev by Date: Re: Ordering polynomials from highest to lowest order
  • Next by Date: Re: how to differentiate a list?
  • Previous by thread: data from mathematica to be saved in ascii format
  • Next by thread: Re: data from mathematica to be saved in ascii format