I want to convert numbers from the following format in a text file:
3.0236E+01
to a plain decimal number in python and add them to a new text file. Is there a way to do this?
Asked
Active
Viewed 119 times
-1
newbie
- 338
- 2
- 12
-
Just `float` with it... – Tomerikoo Aug 12 '20 at 12:59
3 Answers
0
Use float to convert it from scientific notation to the full written number:
float('scientific-notation-string')
float('3.0236E+01')
>>> 30.236
with open('file-with-scientific-notations') as fd:
parsed_numbers = [float(scientific_notation) for scientific_notation in fd.readlines()
with open('dest', 'w') as fd:
for num in parsed_numbers:
fd.write(f'{num}\n')
Or Y
- 1,923
- 1
- 15