Using this code
import re
file = open('FilePath/OUTPUT.01')
lines = file.read()
file.close()
for match in re.finditer(r"(?m)^\s*-+\s+\S+\s+(\S+)", lines):
eng = match.group(1)
open('Tmp.txt', 'w').writelines(eng)
print match.group(1)
I get a column of data that looks like this:
-1.1266E+05
-1.1265E+05
-1.1265E+05
-1.1265E+05
-1.1264E+05
-1.1264E+05
-1.1264E+05
-1.1263E+05
step
-1.1263E+05
-1.1262E+05
-1.1262E+05
-1.1261E+05
-1.1261E+05
-1.1260E+05
-1.1260E+05
-1.1259E+05
step
-1.1259E+05
-1.1258E+05
-1.1258E+05
-1.1258E+05
-1.1257E+05
terminating.
eng_tot
-1.1274E+05
3DHow do I write it a file (Tmp.txt)? As of now it only writes the last line '3D'. Also I'd like to eliminate all the lines that aren't of the form x.xxxxExxx (i.e. just the numbers).