0

ToExpresssion doesn't understand real numbers of the form "1.34e5". How do I convert the string "1.34e5" to a real number in Mathematica?

a06e
  • 11,327
  • 4
  • 48
  • 108
  • I think this question is ill-posed. Mathematica does not normally produce numeric strings of the form in question. Therefore, it seems reasonable to presume the source of the string is external. Should that be the case, then the conversion would be best handled during import. However, becko gives us no information about the source, essentially prohibiting the use of Mathematica;s import mechanisms to solve the problem. – m_goldberg Jun 06 '14 at 22:11
  • ImportString["1.34e5", "Table"][[1, 1]] – ciao Jun 06 '14 at 22:21
  • 1
    ImportString["1.34e5", "JSON"] – m_goldberg Jun 06 '14 at 22:25
  • @RunnyKine - maybe its a duplicate, but this question should remain opened for a while (there are many new users like myself). – eldo Jun 06 '14 at 22:27
  • @m_goldberg The source is a file containing rows of numbers. All rows are not of the same size, so it is not a matrix (therefore Import with option "Table" doesn't work). If that's relevant I can add it to the question. – a06e Jun 06 '14 at 22:33
  • @m_goldberg However, the question as stated, is a valid question. – a06e Jun 06 '14 at 22:34
  • @m_goldberg: AH! +1 on the JSON use, had not thought of that! – ciao Jun 06 '14 at 22:35
  • The fact that there is an external file and the format of the data in that file are both relevant. Pleas add a small sample from your data file to the question. The answer you are seeking will most likely involve Import. – m_goldberg Jun 06 '14 at 22:57

1 Answers1

4

Possibly the simplest solution is

ImportString["1.34e5", "JSON"]
134000.

References:

JSON
Wikipedia

m_goldberg
  • 107,779
  • 16
  • 103
  • 257