Trying to modify a file

Hi , I am a beginner/intermediate at python. I am writing a script for my university project to read a file of data with a header, multiply the middle clumn by 100 and save the changes and save the file in the same exact original format so it’s readable again by a simulation. The complication I cant figure out is that the middle row is a string in term of scientific notation. I don’t know how to convert the format, change the value and write it back in the middle column value. I only want to change the values of the middle column. I attached what I’ve written so far.

Python can recognize numbers in scientific notation. If the values of the middle column are stored in format like 1.2e+3, 1.2E3, 1.2e-2, you can simply use float() function to convert them into floats. But if the values are in other formats, you may use replace() method to modify them into the format that can be recognized by Python, or write a function involves using split() method to get the numeric values before and after the seperator ("e ", " E ", “x10”, or something like that) and then calculate the exact value.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.