Extract value and average
Glauco
glauco.uri at prometeia.it
Tue Jun 9 03:45:23 EDT 2009
Francesco Pietra ha scritto:
> I come 'naked', which is unusual and unfair. However, I find it
> difficult to give a correct start. The files consist, among other
> things, of a huge number of blocks of the type
>
>
> NSTEP = 1000 TIME(PS) = 152.000 TEMP(K) = 298.54 PRESS = 89.4
> Etot = -134965.2123 EKtot = 41282.1781 EPtot = -176247.3905
> BOND = 1771.7644 ANGLE = 6893.3003 DIHED = 4660.1650
> 1-4 NB = 1931.6071 1-4 EEL = 7799.8343 VDWAALS = 19047.1551
> EELEC = -218354.9960 EHBOND = 0.0000 RESTRAINT = 3.7793
> EAMBER (non-restraint) = -176251.1698
> EKCMT = 16048.2253 VIRIAL = 14755.8154 VOLUME = 669299.5681
> Density = 0.9896
> Ewald error estimate: 0.8252E-05
>
>
>
> (in attachment what surely is a correct reproduction of columns)
>
> I would like to extract values corresponding to variable DIHED (here
> 4660.1650) and getting also the mean value from all DIHED.
>
> Thanks for giving a possible attack
>
> francesco pietra
>
If this format is fixed...
vals = [ float(l.split('=')[-1].strip())
for l in file('file.txt','r')
if ' DIHED ' in l ]
mean = sum(vals) / len(vals)
print vals
print mean
Glauco
More information about the Python-list
mailing list