|
1.11.3 Reading Data Files

Reading numerical data files.
If you have a table of numbers in a file, generated for example by an external program, you can read them into Mathematica using ReadList. The numbers in your file can be given in C or Fortran-like form, as 2.3E5 and so on. ReadList converts all numbers to the appropriate Mathematica form.
This shows the contents of the file rand.dat.
In[1]:= !!rand.dat
3.4 -5.7E-2 8.4E+2 4.5 -7.8E-2 1.9E+3 6.4 -0.1 4.7E+4
This reads the file rand.dat, and returns a list of the numbers in the file.
In[2]:= ReadList["rand.dat", Number]
Out[2]= 
This reads the numbers making a separate list for each line in the file.
In[3]:= ReadList["rand.dat", Number, RecordLists -> True]
Out[3]= 
Mathematica allows you to read files in many different ways. For example, instead of reading numbers, you can read strings or "words". In addition, you can use Find to search for particular parts of files to read. These possibilities are discussed in Section 2.11.7.
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT. SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION. |