Skip to content

Instantly share code, notes, and snippets.

@jhjensen2
Last active September 27, 2015 11:42
Show Gist options
  • Save jhjensen2/73f31260f0306e080fe9 to your computer and use it in GitHub Desktop.
Save jhjensen2/73f31260f0306e080fe9 to your computer and use it in GitHub Desktop.
This program finds the last heat of formation in all GAMESS log files for semiempirical geometry optimizations
"""
type "python read.py" to use
This program finds the last heat of formation in all GAMESS log files
for semiempirical geometry optimizations
"""
import string
from glob import glob
for filename in glob("/home/user/*.log"):
f = open(filename,'r')
while 1:
line = f.readline() # read a line from he file
if not line: break # if end-of-file: quit
words = string.split(line) # split line into words
if len(words) < 1:
continue
if words[0] == 'HEAT':
heat = words[-2]
print filename, heat
@baoilleach
Copy link

Apologies for the unrequested code review but some Python idioms that might help:

  1. for line in f: (this replaces lines 15->17)
  2. words = line.split() (replaces 8 and 18)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment