Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to read real numbers in 1.0000e+00 notation

1,270 views
Skip to first unread message

Fedor B. Trintchouk

unread,
May 30, 1996, 3:00:00 AM5/30/96
to

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)


Elizabeth J Earhart

unread,
May 31, 1996, 3:00:00 AM5/31/96
to

In article <4ojegb$7...@dragonfly.wolfram.com>,

Fedor B. Trintchouk <fed...@elmo.Princeton.EDU> wrote:
>
>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^" ?
>

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

David Withoff

unread,
May 31, 1996, 3:00:00 AM5/31/96
to

In article <4ojegb$7...@dragonfly.wolfram.com> fed...@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)
> fed...@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


Paul Abbott

unread,
May 31, 1996, 3:00:00 AM5/31/96
to

Fedor B. Trintchouk wrote:

> 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.

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
_________________________________________________________________


0 new messages