MathGroup Archive 2008

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

Search the Archive

Re: changing the name of exported file without typing

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84753] Re: [mg84732] changing the name of exported file without typing
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sat, 12 Jan 2008 05:20:11 -0500 (EST)
  • Reply-to: hanlonr at cox.net

f[x_] := x^2 + 3;
Table[Export["f" <> ToString[r] <> ".dat", f[r]],
 {r, 0, 2}]

{"f0.dat", "f1.dat", "f2.dat"}

Import /@ %

{{{3}}, {{4}}, {{7}}}


Bob Hanlon

---- Jack Yu <Jack.Yu at astro.cf.ac.uk> wrote: 
> Hello,
> 
> I want to export f[i], where i=0,1,2, into separate files, with respective file names, like f0.dat, f1.dat, f2.dat.  But I do not want to have to type 
> 
> Export["f0.dat",f[0]];
> Export["f1.dat",f[1]];
> Export["f2.dat",f[2]];
> 
> I tried to save energy by using the Do loop 
> 
> Do[Export[Print["f",r,".dat"],f[r]],{r,0,2}]
> 
> but it does not work, saying that the format cannot be recognised from the printed string.  Does anyone know how to loop over the file names?  Any help would be much appreciated.
> 
> Thanks,
> 
> Jack Yu
> 



  • Prev by Date: Re: modular arithmetic (in finite field - part of elliptic curves)
  • Next by Date: Re: Button crashes FrontEnd
  • Previous by thread: Re: changing the name of exported file without typing
  • Next by thread: how restore version 5.2 graphics in 6