I am currently trying to create a python program that prints out specific sections of a file. I tried using file.read() and file.readline() but I can't seem to get an exact position, just either full lines or bits. Is there a better function to be using or an import I can use?
The problem I am running into is my files output reads
facet normal 0.00000e+00 0.00000e+00 0.00000e+00
I want to take the values and put them into a variable. I would like to create an if statement that takes those three values and adds them to different variables however I don't know of a function that does that. Should I be trying to parse the file first?
My code to provide the output is
f = open ('/pycharm/sphere.stl')
for line in f:
print(line)
I would like to have an if statement along the lines of
f = open ('/pycharm/sphere.stl')
for line in f:
if line == "facet normal"
a = nextFloat()
if a == true
b = nextFloat()
if b == true
c = nextFloat()
if c == true
d = a + b + c
print (d)
I am trying to solve for d but I can't find a way to use the output of the file in order to input for d.