Re: ReadList and FortranForm data

*To*: mathgroup at smc.vnet.net*Subject*: [mg8475] Re: [mg8426] ReadList and FortranForm data*From*: David Withoff <withoff>*Date*: Tue, 2 Sep 1997 16:15:12 -0400*Sender*: owner-wri-mathgroup at wolfram.com

> I have never been able to figure out how to read in data from a text > file that is separated by spaces with return characters at the end of > each line. ie > > 1 2 3 4 > 5 6 7 8 > etc. > > The big problem is that Mma interprets the spaces as multiplication > operators. I have tried specifying spaces as WordSeparators, > RecordSeparators, but have not been successful. My work-around is to > read the whole thing in as a String using the Word option, then manually > put commas in where the spaces were and use ToExpression to convert to > numbers again. Unfortunately, this method fails with Fortran-like data > since the e-01 are interpreted as exponentials. Can someone give me the > syntax to read in space separated data please. Have you tried something like this? In[1]:= !!data 1 2 3 4 5 6 7 8 1.7e-12 2.1e17 -5.1 -1.6e99 In[1]:= ReadList["data", Number, RecordLists -> True] -12 17 99 Out[1]= {{1, 2, 3, 4}, {5, 6, 7, 8}, {1.7 10 , 2.1 10 , -5.1, -1.6 10 }} I think the key here is to read numbers in Number format rather than in Expression format. (Expression format is the default.) Dave Withoff Wolfram Research