Re: how to read real numbers in 1.0000e+00 notation
- To: mathgroup at smc.vnet.net
- Subject: [mg4118] Re: how to read real numbers in 1.0000e+00 notation
- From: withoff (David Withoff)
- Date: Wed, 5 Jun 1996 01:38:21 -0400
- Organization: Wolfram Research, Inc.
- Sender: owner-wri-mathgroup at wolfram.com
In article <4ojegb$78s at dragonfly.wolfram.com> fedort at elmo.Princeton.EDU
(Fedor B. Trintchouk) writes:
>
> 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)
> fedort at princeton.edu (609) 258-1139 (fax)
>
>
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
==== [MESSAGE SEPARATOR] ====