Patrick Bradshaw <bradshaw at dirac.scri.fsu.edu> asks:
>Sorry if this is an often-asked question, but I was wondering if there was
>a way (a package?) to read in a formatted data file (using like a "formatted
>read" statement from Fortran).
>
>For example, if a line of the data looks like
>
> 47950 4 9450
>
>I would like to read the data into a list looking like
> {47.950, 4., 9.450}
>
>I looked through MathSource and didn't find anything, but perhaps I
>overlooked something.
>
Patrick,
You can do this with the built-in command ReadList. Herew is an example,
using the option RecordLists -> True which causes each line of the input
file to be placed on a separate sublist.
In[1]:=
!!readtest (* First look at the file *)
47950 4 9450
75320 2 8310
23093 6 9234
In[2]:=
ReadList[ "readtest", Number, RecordLists -> True]
Out[2]=
{{47950, 4, 9450}, {75320, 2, 8310}, {23093, 6, 9234}}
I hope this helps,
--Ian