MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: how to get string in sci. notation to a number?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123344] Re: how to get string in sci. notation to a number?
  • From: Ralph Dratman <ralph.dratman at gmail.com>
  • Date: Fri, 2 Dec 2011 07:21:44 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jb2hum$5e0$1@smc.vnet.net>

But that is so easy with pattern replacement. More experienced people
will surely manage it without using StringReplace, but I get flummoxed
on which kind of Hold to use.

In[652]:= flpnumsStr =
 ToString[{{"4.998865e+000", "9.564453e-006"}, {"5.630450e+000",
   "9.194384e-006"}, {"6.113276e+000", "8.134170e-006"}}]

Out[652]= "{{4.998865e+000, 9.564453e-006}, {5.630450e+000,
9.194384e-006}, {6.113276e+000, 8.134170e-006}}"

In[653]:= ToExpression[StringReplace[flpnumsStr, "e" -> "*10^"]]

Out[653]= {{4.99887, 9.56445*10^-6}, {5.63045,
 9.19438*10^-6}, {6.11328, 8.13417*10^-6}}

Ralph Dratman


On Thu, Dec 1, 2011 at 5:53 AM, Chris Degnen <degnen at cwgsy.net> wrote:
> A few more variations:-
>
> data={
> {"4.998865e+000","9.564453e-006"},
> {"5.630450e+000","9.194384e-006"},
> {"6.113276e+000","8.134170e-006"}};
>


> a=ImportString[ExportString[data,"Table"]];
>
> Export["data.dat",data];
> b=Import["data.dat"];
>
> c=ReadList["data.dat",{Number,Number}];
>
> Export["data.csv",data];
> d=Import["data.csv"]
>
> a===b===c===d
>
>
> On Nov 29, 12:07 pm, "1.156" <r... at piovere.com> wrote:
>> I've been able to get a text file with data into a list of strings
>> of the following form:
>>
>> {{"4.998865e+000", "9.564453e-006"},
>>   {"5.630450e+000", "9.194384e-006"},
>>   {"6.113276e+000", "8.134170e-006"}}
>>
>> After many hours I've really gotten nowhere except that it's most
>> likely done with ToExpression which works fine with simple decimal
>> numbers in string form. Must I really split up the strings, suck out the
>> exponents, and then multiply them out to be able to use these numbers in
>> a ListPlot?
>> Any hints would be appreciated.
>> --
>> Sent from my plain desktop PC.
>
>



  • Prev by Date: Re: Ploting a transformation of a set
  • Next by Date: Re: NIntegrate with AdaptiveMonteCarlo gives different results
  • Previous by thread: Re: how to get string in sci. notation to a number?
  • Next by thread: Re: how to get string in sci. notation to a number?