# Trying to replace the text E with scientific notation

How to replace the E with scientific notation *^?

{0.1971468 E - 001, 0.1422880 E - 001, 0.2046836 E - 001,
0.1394519 E - 001, -0.9795244 E - 002, 0.1424443 E - 001} /. E -> *^

• Where does this data come from? That's certainly not Mathematica syntax for expressing scientific notation. Did it come as a string? – b3m2a1 Dec 21 '19 at 9:16
• it's a TextPad data imported into Mathematica – acoustics Dec 21 '19 at 9:18
• StringReplace["{0.1971468 E-001,0.1422880 E-001,0.2046836 \ E-001,0.1394519 E-001,-0.9795244 E-002,0.1424443 E-001}", "E" -> "*^"] – Xminer Dec 21 '19 at 9:18
• How'd you import it? Copy paste? – b3m2a1 Dec 21 '19 at 9:18
• I'd say "How to replace E?" is the wrong question. The right question would be: how to import that data? It's hard to tell without seeing your datafile, but most likely Import[..., "Table"]. – Szabolcs Dec 21 '19 at 18:45

a = Import["modeshapes_evolution.txt", "Lines"];
b = StringSplit[a, ","];
c = StringReplace[#, "E - " -> "*10^-"] &  /@ b;
data = ToExpression[c]


The above works on a text file with lines that contain your sample data.

Better method:

To use MMA's built-in data format conversion, as suggested by @Roman, you could simply remove the spaces and read the text as data:

s = Import["modeshapes_evolution.txt", "String"];
data = ImportString[StringReplace[s, " " -> ""], "Data"]


The input as a string (maybe read from a file):

S = "{0.1971468 E - 001, 0.1422880 E - 001, 0.2046836 E - 001,
0.1394519 E - 001, -0.9795244 E - 002, 0.1424443 E - 001}";


Delete whitespace and curly braces, then import as CSV:

ImportString[StringDelete[S, "{" | "}" | " " | "\n"], "CSV"]
(*    {{0.0197147, 0.0142288, 0.0204684, 0.0139452, -0.00979524, 0.0142444}}    *)


From the documentation: "Import automatically recognizes common number formats, including C and Fortran notations."

Maybe it's enough to import your entire file as CSV instead of as Text.

In Mathematica 12 both do not work

(i) direct input of the given list,

(ii) first enter = and then the list

because all suppress or ignore the E.

Just in the expansion of the link "Show all solution" the E is identified.

The solution is the step suggested by Xminer after entering the = for the Wolfram Alpha type of input interpretation and 10 instead of *. The trick is not to enter

StringReplace["{0.1971468 E-001,0.1422880 E-001,0.2046836 \ E-001,0.1394519 E-001,-0.9795244 E-002,0.1424443 E-001}","E"->" 10^"]


direct in the = line, but to copy and paste the output 