I am trying to write a simple program to edit existing numbers in a text file using the pandas library.
I have a text file with the following format:
"===================================================================================================================================="
----- whole bunch of text here -----
"===================================================================================================================================="
"variable1","Variable2","Variable3"
"unit1","unit2","unit3"
------,------,------
1,0.800,12161.31
2,0.883,1623669.24
------ some other stuff here ----------
I am interested in only the two numbers under variable3/unit3 : 12161.31 and 1623669.24
I would like to be able to add/subtract numbers from these values.
Currently, I can seperate the values of interest from the txt file by a pd.read_csv method:
data = pd.read_csv(str(infilename), sep ='/t', header = None, skiprows = 2, index_col = None)
new_data = data[24:26]
print(new_data)
out:
24 1,0.800,12161.31
25 2,0.883,1623669.24
However, I cannot think of a way to replace the original values with the newly edited ones. Is this possible using the pandas library?