Re: Reading in a file

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

On 5/12/05 at 2:34 AM, swatshah at gmail.com (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 = >{3.1,4.1,2.3,4.5,3.3,2.5,1.1,4.1} >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}] where data = Import["temp.txt", "Table"]; -- To reply via email subtract one hundred and four