On 12/2/11 at 7:21 AM,
ralph....@gmail.com (Ralph Dratman) wrote:
>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}}
I assume you really didn't manually enter the strings in the
form of Mathematica lists. So, let me start by putting the
output of your ToString above into something that likely
resembles the original data, i.e.,
In[5]:= p =
StringReplace[
StringTake[
ToString[{{"4.998865e+000", "9.564453e-006"}, {"5.630450e+000",
"9.194384e-006"}, {"6.113276e+000",
"8.134170e-006"}}], {3, -3}], "}, {" -> "\n"]
Out[5]= 4.998865e+000, 9.564453e-006
5.630450e+000, 9.194384e-006
6.113276e+000, 8.134170e-006
Now, these can be read in as numbers simply by using ImportString
In[6]:= ImportString[p, "CSV"]
Out[6]= {{4.998865, 9.564453*^-6}, {5.63045, 9.194384*^-6},
{6.113276, 8.13417*^-6}}