Re: how to get string in sci. notation to a number?
- To: mathgroup at smc.vnet.net
- Subject: [mg123283] Re: how to get string in sci. notation to a number?
- From: "Oleksandr Rasputinov" <oleksandr_rasputinov at hmamail.com>
- Date: Wed, 30 Nov 2011 03:21:11 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jb2hum$5e0$1@smc.vnet.net> <jb2kp7$6j4$1@smc.vnet.net>
On Tue, 29 Nov 2011 12:56:07 -0000, Oleksandr Rasputinov <oleksandr_rasputinov at hmamail.com> wrote: > > In place of "e", Mathematica uses "*^". When reading output from a Python > program into Mathematica for analysis, I have used StringReplace to > convert to valid Mathematica syntax followed by ToExpression; this can be > faster and more convenient than Import in certain cases. Actually that approach might be convenient here too, and definitely faster than ImportString on each element for large tables of values... ToExpression@Internal`Deflatten[ (* StringReplace doesn't like nested lists... *) StringReplace[Flatten[lst], "e" -> "*^"], Dimensions[lst] ] {{4.99887, 9.56445*10^-6}, {5.63045, 9.19438*10^-6}, {6.11328, 8.13417*10^-6}}