首页 > 解决方案 > 使用 nupy genfromtxt, python 加载数据的问题

问题描述

我的文本文件 ( test.out) 包含的数据排列为三行,但每行的列数不同。如下图所示

2013  531 1155 24.0 L  19.219  76.766  0.2  JOY  3 0.0 0.4LJOY                1
CBN  SZ IPg      1155 26.58                              87    0.0110 15.1 134
CBN  SN ESg      1155 28.38                              87   -0.0210 15.1 134 

使用 import numpy as np 加载数据时显示错误

d1=np.genfromtxt('test.out', dtype=str)

它显示错误消息: raise ValueError(errmsg)

ValueError: Some errors were detected !
    Line #2 (got 9 columns instead of 13)
    Line #3 (got 9 columns instead of 13)

如何使用 numpy 加载它genfromtxt。如果有人可以提供帮助,那对我来说将是很大的帮助。提前致谢。

标签: pythongenfromtxt

解决方案


推荐阅读