Related data repo.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233
  1. import numpy as np
  2. import csv
  3. import pdb
  4. wFile = open("output.dat",'r')
  5. gridNN = 0
  6. line = wFile.readline()
  7. while line != "\n" :
  8. if line.lstrip()[0] != "#" :
  9. lineData = line.split()
  10. varNN = len(lineData)
  11. gridNN += 1
  12. line = wFile.readline()
  13. wFile.seek(0,0)
  14. data = []
  15. tmp = np.zeros([gridNN,varNN])
  16. gridII = 0
  17. for line in wFile :
  18. if (line == "\n") and (gridII != 0) :
  19. data.append(tmp)
  20. tmp = np.zeros([gridNN,varNN])
  21. gridII = 0
  22. elif (line != "\n") and (line.lstrip()[0] != "#") :
  23. tmp[gridII,:] = np.array(line.split(),dtype=float)
  24. gridII += 1
  25. np.save("output.npy",data)