MathGroup Archive 1996

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

Search the Archive

Re: [Q]: Reading Input

  • Subject: [mg3216] Re: [mg3192] [Q]: Reading Input
  • From: rbowman at Bridgewater.EDU (Richard Bowman)
  • Date: 17 Feb 1996 22:25:17 -0600
  • Approved: usenet@wri.com
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: Wolfram Research, Inc.
  • Sender: daemon at wri.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
-------------------------------------------------------------------------



  • Prev by Date: Re: [Q]: Reading Input
  • Next by Date: Re: What is Mathmatica
  • Previous by thread: Re: [Q]: Reading Input
  • Next by thread: Re: [Q]: Reading Input