- To: mathgroup at smc.vnet.net
- Subject: [mg60388] Re: [mg60364] Batch
- From: "David Annetts" <davidannetts at aapt.net.au>
- Date: Thu, 15 Sep 2005 05:16:11 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi Maria, > I need to run a batch in Mathematica, so that I read data > from several files and execute the calculations and generate > the graphics. > Then I read another group of data and perform the same > calculation and that goes on until the data finish. > > I just manage to do this by putting all the calculation > in a single cell, inside a Do. My cases are rather large, I > am dealing with experimental data and I have to manipulate > files with 1,000,000 points. > I cannot just read all of them at once and start the calculus. > > My first go was to separate the calculations in notebooks > and one nb called the next one. The first notebook called the > following without a problem, but it did not evaluate it. I > had to do it manually. And I have around 100 cases to > analyse. I really need to automatize the procedure. My suggestion is to save each notebook as a package (File->Save as special->Package format). This will leave you with a series of files that you can happily batch, either from your operating system, or through Mathematica. For example, we can generate some files using ( ount = OpenWrite[onam[[#]]]; ostr = "Print[\"Hi from file : \", "; ostr = StringJoin[ostr, ToString[#], "];"]; Write[ount, OutputForm[ostr]]; Close[ount]; ) & /@ Range[Length@onam] Then, under Windows, we can run them sequentially using the batch file c:\Mathematica\5.0.1\math < File_0001.m c:\Mathematica\5.0.1\math < File_0002.m c:\Mathematica\5.0.1\math < File_0003.m c:\Mathematica\5.0.1\math < File_0004.m c:\Mathematica\5.0.1\math < File_0005.m You will probably have to change the path to math.exe. Note that this is not the front end, nor even the kernel, but a text-mode front end. It is also worth noting that we can use Mathematica to run the batch process using the following code ifil = FileNames["*.m"] ( Print["Working on file : ", ifil[[#]]]; Get[ifil[[#]]]; ) & /@ Range[Length@ifil] Regards, Dave.