I have to read into mathematica ASCII data files containing floating
point numbers in the notation
that uses the character "e" to separate mantissa and exponent. Is there a
mathematica function that converts this into mathematica's proper
representation, or do I have to use sed or something similar to
replace e's by something like "*10^" ?
Thank you.
--
--
Fedor Trintchouk (609) 258-4745 (office/voice)
Princeton University (609) 258-1089 (lab)
fed...@princeton.edu (609) 258-1139 (fax)
Read[<channel>,Number] will properly read numbers in this format.
You may need to mess around with the WordSeparators and RecordSeparators
options (e.g. if your file is comma-delimited).
-Elizabeth Earhart
The Number format in Read and ReadList can read number in "e" notation.
In[1]:= !!datafile
1.73e+8 2.75e+7 -16.9e-11
In[1]:= ReadList["datafile", Number]
8 7 -10
Out[1]= {1.73 10 , 2.75 10 , -1.69 10 }
Also, if you think you need it, a sed script sci2mma is available
on MathSource (item 0206-345: sci2mma -- A Filter to Convert Data
in Scientific Notation Format to Mathematica Input Format).
Or the converter could easily be written in Mathematica rather
than sed, in case you need it on a machine that doesn't have sed.
Dave Withoff
Research and Development
Wolfram Research
See page 494 of the bible (i.e. Wolfram's book).
Cheers,
Paul
_________________________________________________________________
Paul Abbott
Department of Physics Phone: +61-9-380-2734
The University of Western Australia Fax: +61-9-380-1014
Nedlands WA 6907 pa...@physics.uwa.edu.au
AUSTRALIA http://www.pd.uwa.edu.au/Paul
_________________________________________________________________