import numpy as np import csv import pdb wFile = open("output.dat",'r') gridNN = 0 line = wFile.readline() while line != "\n" : if line.lstrip()[0] != "#" : lineData = line.split() varNN = len(lineData) gridNN += 1 line = wFile.readline() wFile.seek(0,0) data = [] tmp = np.zeros([gridNN,varNN]) gridII = 0 for line in wFile : if (line == "\n") and (gridII != 0) : data.append(tmp) tmp = np.zeros([gridNN,varNN]) gridII = 0 elif (line != "\n") and (line.lstrip()[0] != "#") : tmp[gridII,:] = np.array(line.split(),dtype=float) gridII += 1 np.save("output.npy",data)