Message Boards Message Boards

2 Replies
0 Total Likes
View groups...
Share this post:

Converting Excel scientific notation (type "text") to Real in Mathematica

I have some sample data (probably from a database, originally), transmitted to me in Excel. Every field in the spread sheet has Excel type "text".

Import converts everything to type String in Mathematica. Applying ToExpression to the values with Head String does the right thing - converting to Head Integer, Real, or String - EXCEPT for one case.

In[667]:= tripleStore2[[8, 3]]

Out[667]= "8.9012234042552939E-3"

In[668]:= ToExpression[%]

Out[668]= 21.196

I'm assuming Mathematica sees "E" as the base of natural logarithms ... ?

Before I try to write the appropriate micro-parser, is there a Mathematica function I can use? Or is there code somewhere that does what I need?

Thank you, -- Mark

POSTED BY: Mark Tuttle
2 Replies

Perfect. I really appreciate your quick response.

Either I failed or the documentation hypertext failed. I didn't find the nicely related example in the documentation for Interpreter.

-- Mark

POSTED BY: Mark Tuttle

If you look online, you'll find many different solutions to this.

In version 10, I would suggest using:


SemanticImport might be able to do this all for you instead of Import. It works okay for simple files, but might need some guidance on the kind of output you're expecting it.

POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract