MathGroup Archive 1996

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

Search the Archive

Re: [Q]: Reading Input

  • To: mathgroup at smc.vnet.net
  • Subject: [mg3216] Re: [mg3192] [Q]: Reading Input
  • From: Richard Bowman <rbowman at Bridgewater.EDU>
  • Date: Sat, 17 Feb 1996 14:18:00 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

To read input in x.xExx format such as that generated by Fortran programs 
specify the type of data as "Real".  For example, I put the following 
data into the file with a title of "data.txt"

    2.34E-4  9.87E15

Then I used the following Mathematica code to read it:

In[4]:= ReadList["data.txt",Real,RecordSeparators->{"\n"," "}]

                          15
Out[4]= {0.000234, 9.87 10  }

The E-format is not preserved, but the numbers are stored correctly for 
use by Mathematica.  If a given line is to go into a separate row in the 
resulting list, then the option "RecordLists->True" must be used.  If the 
data is separated by something other than "new line" codes and "spaces," 
then the RecordSeparators list needs to be adjusted appropriately.

-------------------------------------------------------------------------
Dr. Richard L. Bowman
Dept. of Physics                         e-mail:  rbowman at bridgewater.edu
Bridgewater College                                  phone:  540-828-5441
Bridgewater, VA  22812                                 FAX:  540-828-5479
-------------------------------------------------------------------------


==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Help with ErrorListPlot
  • Next by Date: Re: [Q]: Reading Input
  • Previous by thread: [Q]: Reading Input
  • Next by thread: Re: [Q]: Reading Input