Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
can someone help me, I am trying to extract some data from the str file using python
the thing is that I am able to read the data and print it but I can not search for the data using the line.startswith
how to deal with .str using python
this is a small example not the full code
with open(SourceFile,"r") as file: # where SourceFile = Structure.str
for line in file:
if line.startswith(" NODes \n"😞 # search for a keyword
printing = True
continue # go to next line
elif line.startswith(" ;CON"😞
printing = False
break #quit file reading
if printing:
print(line, file=PointsFile) # where PointsFile = a txt file to save the extracted points data to it
PointsFile.close()
Solved! Go to Solution.