Here is a part of my parser. The problem is that it not reading and printing DeltaE and Intensity maybe someone could help ?
if (line[1:24] == "Mulliken atomic charges" or
line[1:22] == "Lowdin Atomic Charges"):
if not hasattr(self, "atomcharges"):
self.atomcharges = {}
ones = inputfile.next()
charges = []
nline = inputfile.next()
while not "Sum of" in nline:
charges.append(float(nline.split()[2]))
nline = inputfile.next()
if "Mulliken" in line:
self.atomcharges["mulliken"] = charges
else:
self.atomcharges["lowdin"] = charges
if line[0:6] == 'DeltaE':
while not "DeltaE" in nline:
deltae = []
intensity = []
line=line.strip()
#then we have a line like: DeltaE = 13.5423 | TDMI^2 = 0.6670E-01, Intensity = 6553.
self.deltae = float(line.split('|')[0].strip().split('=')[1].strip())
line = inputfile.next()
self.intensity = float(line.split('|')[1].strip().split(',')[1].strip().split('=')[1].strip())
line = inputfile.next()
print deltae, ',', intensity
Part of output.log file (this output.log is very huge like 15mb)
Initial state: <0|
Final state: |1^1>
DeltaE = 13.5423 | TDMI^2 = 0.6670E-01, Intensity = 6553.
........................................
Initial state: <0|
Final state: |2^1>
DeltaE = 17.9918 | TDMI^2 = 0.2693 , Intensity = 0.2668E+05
........................................
Initial state: <0|
Final state: |3^1>
DeltaE = 22.4523 | TDMI^2 = 0.4740E-01, Intensity = 4644.
........................................
I want to print DeltaE and Intensity after using parse method but nothing is working i can get other values but not DeltaE and Intensity:
>>> mylogfile.parse()
[Gaussian BChla.out INFO] Creating attribute charge: 0
[Gaussian BChla.out INFO] Creating attribute mult: 1
[Gaussian BChla.out INFO] Creating attribute natom: 82
[Gaussian BChla.out INFO] Creating attribute atommasses[]
[Gaussian BChla.out INFO] Creating attribute atomnos[]
[Gaussian BChla.out INFO] Creating attribute vibsyms[]
[Gaussian BChla.out INFO] Creating attribute vibfreqs[]
[Gaussian BChla.out INFO] Creating attribute vibirs[]
[Gaussian BChla.out INFO] Creating attribute vibdisps[]
[Gaussian BChla.out INFO] Creating attribute temperature: 298.15
[Gaussian BChla.out INFO] Creating attribute enthaply: -2225.475525
[Gaussian BChla.out INFO] Creating attribute freeenergy: -2225.601048
[Gaussian BChla.out INFO] Creating attribute grads[]
[Gaussian BChla.out INFO] Creating attribute entropy: 0.000421006204931
[Gaussian BChla.out INFO] Creating attribute atomcoords[]
[Gaussian BChla.out INFO] Creating attribute coreelectrons[]
<cclib.parser.data.ccData object at 0x02FA1890>
>>>
line[0:11] == 'DeltaE'looks incorrect to me,DeltaEis 6 characters but you are extracting 11 from the line to compare it against. Alsonlineis not modified inside thewhile not "DeltaE" in nlineloop, so this loop will either short circuit or will execute forever. This is a fragile and error prone way to write a 'parser'.deltae = [] intensity = []and print them out, but never assign anything to them.