Since this format with 'HEAD' and 'END' is not known about by numpy.loadtxt
, I think you will have to "chunk" those arrays yourself:
import numpy as np
def tokenizer(fname):
with open(fname) as f:
chunk = []
for line in f:
if 'HEAD'in line:
continue
if 'END' in line:
yield chunk
chunk = []
continue
chunk.append(line)
arrays = [np.loadtxt(A) for A in tokenizer('yourfile.txt')]