Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: exporting numerical data

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106673] Re: exporting numerical data
  • From: shinytinkerbell <shinytinkerbell at googlemail.com>
  • Date: Thu, 21 Jan 2010 04:49:29 -0500 (EST)

Ok, I've written my own function for doing this but I really strongly
believe that it would be very useful to introduce such function "by
default" in next version of Mathematica. It's so natural that people
would like/need store their data in such a way, isn't it?
I paste my function, maybe it will help somebody else.

Export3Darray[fname_String, lst_List, Ni_, Nj_] :=
  Module[{f, ReducedArray}, f = OpenAppend[fname, FormatType ->
CForm];
   For[i = 0, i < Ni, i += 1,
     For[j = 0, j < Nj, j += 1,
      ReducedArray = lst[[i + 1, j + 1]];
      WriteString[f, ToString[ReducedArray[[1]]], "\t",
       ToString[ReducedArray[[2]]], "\t", ToString[ReducedArray[[3]]],
        "\n"];
      Clear[ReducedArray];
      ]
     ]
    Close[f];
   ];

You can easily extend/change this particular function to any dimension
of your array.
--
Regards,
tinkerbell


  • Prev by Date: Re: Sorting paired columns of dates and values
  • Next by Date: Text Output
  • Previous by thread: exporting numerical data
  • Next by thread: Re: exporting numerical data