MathGroup Archive 2005

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

Search the Archive

Re: Reading in a file

  • To: mathgroup at
  • Subject: [mg57036] Re: Reading in a file
  • From: Bill Rowe <readnewsciv at>
  • Date: Thu, 12 May 2005 22:44:18 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

On 5/12/05 at 2:34 AM, swatshah at (Swati Shah) wrote:

>Hi everyone, I have the following file named "temp.txt" with the
>following format:

>;  Restart file created by make.m
>NYTOT        140
>STTOT         30
>TIME 0.00000000000000
>3.1     4.1
>2.3    4.5
>3.3     2.5
>1.1    4.1

>I want to read this file in, but store the value of NYTOT which is
>140 in a variable nytot, sttot in another variable named sttot

>At the end, I would like the get nytot = 140 sttot = 30 time = 0.0

>and the rest of the values in another list: tmpLst =

>I have done the following so far:

>tmpLst=Flatten[Select[Import["temp.txt", "Table"],
>NumericQ[First[#]] &]]; Which gives the tmpLst values but am not
>sure how I can get the sttot, nytot and time values?

Assuming the variables sttot, nytot and time don't exist the following will do the trick

Set[Evaluate[ToExpression@ToLowerCase@First@#], Last@#]&/@Cases[data, {_String, _Real | _Integer}]


data = Import["temp.txt", "Table"];
To reply via email subtract one hundred and four

  • Prev by Date: Re: GramSchmidt problem
  • Next by Date: Re: MapThread
  • Previous by thread: Re: Reading in a file
  • Next by thread: NDSolve. SolveDelayed->True