Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6848 > unrolled thread
| Started by | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| First post | 2011-11-30 08:31 +0000 |
| Last post | 2011-11-30 08:31 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: how to get string in sci. notation to a number? Bob Hanlon <hanlonr357@gmail.com> - 2011-11-30 08:31 +0000
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Date | 2011-11-30 08:31 +0000 |
| Subject | Re: how to get string in sci. notation to a number? |
| Message-ID | <jb4pl3$gvg$1@smc.vnet.net> |
data = {{"4.998865e+000", "9.564453e-006"}, {"5.630450e+000",
"9.194384e-006"}, {"6.113276e+000", "8.134170e-006"}};
data2 = Map[ToExpression[StringSplit[#, "e"]] &,
data, {2}] /.
{m_?NumericQ, e_} -> m*10^e
{{4.99887, 9.56445*10^-6}, {5.63045, 9.19438*10^-6}, {6.11328, 8.13417*10^-6}}
data3 = data /.
x_String :> ToExpression[StringSplit[x, "e"]] /.
{m_?NumericQ, e_} ->
m*10^e
{{4.99887, 9.56445*10^-6}, {5.63045, 9.19438*10^-6}, {6.11328, 8.13417*10^-6}}
Although you should be able to automatically convert the data on import
data4 = Import[Export["test.txt", data, "Table"], "Table"]
{{4.99887, 9.56445*10^-6}, {5.63045, 9.19438*10^-6}, {6.11328, 8.13417*10^-6}}
data2 == data3 == data4
True
Bob Hanlon
On Tue, Nov 29, 2011 at 7:04 AM, 1.156 <rob@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.
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web