#!/usr/bin/python import sys # V1 -- from fchk # Find: # Force constants in Cartesian coordinates: # # Ends with: # FormGI is forming the generalized inverse of G from B-inverse, IUseBI=4. # Force constants in internal coordinates: # # Count line. Need same amount of columns. Five columns per echo. N/5 def getrawdata(infile): items=0 countlines=0 flathessian=[] f=open(infile,'r') found=False for line in f: line=line.rstrip('\n') if found==True: data=filter(None,line.split(' ')) for n in range(0,len(data)): flathessian+=[float(data[n])] countlines+=1 if "Cartesian Force Constants" in line: found=True data=filter(None,line.split(' ')) items=int(data[data.index("N=")+1]) if countlines==items: found=False f.close() return flathessian def saveflathessian(rawdata,outfile): g=open(outfile,'w') for n in range(0,len(rawdata)): formdata="%1.10e" % (rawdata[n]) if float(formdata)>0.0: formdata=' '+formdata g.write(' '+str(formdata)+'\n') g.close() return 0 if __name__ == "__main__": infile=sys.argv[1] outfile=sys.argv[2] rawdata=getrawdata(infile) saveflathessian(rawdata,outfile)