【发布时间】:2016-02-01 18:39:28
【问题描述】:
.txt 文件中有很多数据。
它看起来像这样:
# T1 T2 T3 T4 T5 T6 T7 T8
1 20.67 20.70 20.73 20.76 20.69 20.73 20.66 20.72
2 20.68 20.70 20.74 20.75 20.69 20.73 20.66 20.72
我想找到最大值/最小值。使用 Python 脚本的值。
首先我试图找出T1 列的最大值是多少。
这是我的(非常非常简单的)代码:
import numpy as np
T1 = np.genfromtxt('data.txt', unpack=True)
T1_max=np.maximum(T1)
print("T1_max")
当我尝试运行它时,我收到如下错误消息:
Line #7816 (got 10 columns instead of 1)
Line #7817 (got 10 columns instead of 1)
Line #7818 (got 10 columns instead of 1)
Line #7819 (got 10 columns instead of 1)
Line #7820 (got 10 columns instead of 1)
Line #7821 (got 2 columns instead of 1)
(它从第 2 行开始(得到 10..)。 它必须是“np.genfromtxt”函数。我必须添加什么论据才能使其发挥作用?或者你知道如何启动一个替代脚本来输出最大值/最小值。价值观?
谁能帮帮我?
【问题讨论】:
-
欢迎来到 StackOverflow。如果您需要调试帮助,您应该清楚地解释具体的问题或错误是什么。现在你还没有在你的问题中说明这一点,尽管我可以猜测
np.genfromtxt没有返回你认为应该的内容(提示:read the documentation,特别是关于unpack参数的部分)。 -
这些是我收到的错误: Line #7816(得到 10 列而不是 1)>Line #7817(得到 10 列而不是 1)>Line #7818(得到 10 列而不是 1) >Line #7819(得到 10 列而不是 1)>Line #7820(得到 10 列而不是 1)>Line #7821(得到 2 列而不是 1)(我刚刚复制了最后几行,但它与 Line # 2(有 10 列...)
-
第 7815 到 7820 行是什么样的?将它们发布在您的问题中。可能你的文本文件格式不一致。