1 | initial version |
Here is a simple script to get the contingencies names from a .con
file:
contingency_names = []
with open('contingency.con') as confile:
for line in confile:
if line.strip().lower().startswith('contingency'):
# assumes the last word on the line is the contingency name.
words = line.split(' ')
name = words[-1]
contingency_names.append(name)
print contingency_names
I've assumed that your file looks a bit like this:
CONTINGENCY firstcontingency
REMOVE UNIT 3 FROM BUS 20002
END
CONTINGENCY somethingelse
...
The script wont work if:
CONTINGENCY
line other than the word CONTINGENCY
and the contingency nameDoes it work for you?