MathGroup Archive 2005

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

Search the Archive

Re: FileNamesin a loop..

  • To: mathgroup at
  • Subject: [mg62113] Re: FileNamesin a loop..
  • From: Uli <uli.wuerfel at>
  • Date: Sat, 12 Nov 2005 03:31:11 -0500 (EST)
  • References: <dl1jf2$t7d$>
  • Sender: owner-wri-mathgroup at

Bill Rowe schrieb:
> On 11/10/05 at 2:50 AM, uli.wuerfel at (Uli Würfel)
> wrote:
>>I want to carry out the same calculation repeatedly, but with
>>different sets of parameters. The parameters are located in files
>>and I tried to use
>>dateien = FileNames["para*.txt"]
>>Then, I wanted to use a simple loop in the way:
>> str=OpenRead[dateien[[i]]];
>> ---- Reading of parameters ---
>> Close[str];
>> -----calculations---
>>Unfortunately, it does not work. Could you help?
> What you have outlined above should work. The fact that it doesn't work indicates the problem is with the parts of the code you didn't post. So without additional detail, it is impossible to identify the issue. However, it might be worth pointing out the For loop isn't needed. Instead you could structure things as follows:
> parameterReadFunction[filename_String]:= ...
> caluculationFunction[parameters...]:= ...
> calculationFuction[paramterReadFunction@#]&/@FileNames["para*.txt"]
> One of the advantages of structuring the code this way is it makes it easier to debug.
> --
> To reply via email subtract one hundred and four
Hello Bill,

thank you for your help. You were right, there was a bug in the other 
part of the code...
I will try to apply your structure.


  • Prev by Date: Re: Write, Put,..
  • Next by Date: Re: feature request: invert plot axes
  • Previous by thread: Re: FileNamesin a loop..
  • Next by thread: Kronecker Product with SparseArray