Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: FileNamesin a loop..

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62113] Re: FileNamesin a loop..
  • From: Uli <uli.wuerfel at fmf.uni-freiburg.de>
  • Date: Sat, 12 Nov 2005 03:31:11 -0500 (EST)
  • References: <dl1jf2$t7d$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Bill Rowe schrieb:
> On 11/10/05 at 2:50 AM, uli.wuerfel at fmf.uni-freiburg.de (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:
> 
> 
>>For[i=1,i<=Length[dateien],
>>{
>> str=OpenRead[dateien[[i]]];
>> ---- Reading of parameters ---
>> Close[str];
>> -----calculations---
>>};
>>i++]
> 
> 
>>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.

Regards,
Uli


  • 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