I am trying to do a little bit of numeric computing. I wrote a program that writes the result of each iteration of a function to a file. I want to graph these results as dots using vpython, but I am unable to do so.
I need each value to be on its own line in the text file, so I am using this to write the value to the text file:
currenttotal is the value produced by the function
squarerootfile is the object for the file it is written to
Then I run the text file through another program that plots the line number as the x coordinate and the value as the y coordinate. The program reads the file using this:
The value is returned as '0.5\n'. I need to convert this to the float 0.5. Is there a command for this? Or do I need to change the first program to not write strings? How do I do this and get it to put the next value on the next line?
Thank you,
Gordon
I need each value to be on its own line in the text file, so I am using this to write the value to the text file:
Code:
written=str(currenttotal)
squarerootfile.write(written)
squarerootfile.write("\n")
squarerootfile is the object for the file it is written to
Then I run the text file through another program that plots the line number as the x coordinate and the value as the y coordinate. The program reads the file using this:
Code:
path="c:\\pythonfiles2\\totalsqrt32.txt" input=file(path) input.readline()
Thank you,
Gordon
Comment