从具有不同大小的行的txt读取值到单个numpy数组中

can*_*sin 2 python arrays io numpy scipy

我需要读取一个结构如下的文件:

 1 2 3 4 5
 6 7 8 9 10
 11 22
 13 14 15 16 17
 18 19 20 21 22
 23 24
Run Code Online (Sandbox Code Playgroud)

我需要在一个数组中读取这个文件= [1,2,3,...,23,24]

如何在numpy中做到这一点?使用设:

Array = np.genfromtxt(pathToFile, dtype=float, skip_header=1, comments='/')
Run Code Online (Sandbox Code Playgroud)

没工作:

Line #796537 (got 2 columns instead of 5)
Run Code Online (Sandbox Code Playgroud)

Bit*_*ise 5

更简单的方法:

result=np.fromfile(path_to_file,dtype=float,sep="\t",count=-1)
Run Code Online (Sandbox Code Playgroud)