I would like to read many numbers from a Gaussian formatted checkpoint file. The corresponding part looks like this:
Cartesian Force Constants R N= 17391
6.82119997E-01 1.28823797E-01 4.64548230E-01 8.16802733E-02 -2.63533593E-01
4.30400615E-01 -1.41139143E-01 4.62611793E-02 -7.32145345E-02 6.16655830E-01
...
N number means I have to read 17391 doubles, which are in 3479 lines. The file is too huge to read all of the lines, I look for a smarter solution.
What I have tried so far: I searched the expression with a for loop
fchk = open(filepath,'r')
for line in fchk:
if "Cartesian Force Constants" in line:
header = line
count = int(header[50:62])
Elements = np.empty([count],dtype=np.float_)
After this if I try read more line inside or outside the previous for loop I got
ValueError: Mixing iteration and read methods would lose data