Python-Using Numpy,如何从.txt文件中读取数据并将数据列分配给变量

时间:2017-02-07 01:28:48

标签: python database list numpy

p3txt=np.loadtxt("data_.txt")

` 是长文本文件的示例以及它们在列中的方式。我问如何在将这些列分配给python的一行变量时如何读取文件并将这些列分开?每当我尝试将.txt转换为float类型

时,我都会收到错误
public class IdDetails
{
    public string transactionDate { get; set; }
    public string upnName { get; set; }
    public string movementTrade { get; set; }
    public string baseCurve { get; set; }
    public string cTolerance { get; set; }
    //17 more declarations below
}

是我现在正在阅读的文件

1 个答案:

答案 0 :(得分:1)

尝试:

skiprows=1  ->  skip the first row (because it doesn't contain numbers)
.T          ->  take transpose. numpy is [row-major](https://en.wikipedia.org/wiki/Row-_and_column-major_order) meaning that when splitting up the data it will first cut up the columns and leave the rows as whole
a, b        ->  assigning to a tuple of variables triggers the splitting up of the right-hand-side

说明:

FilterRegistrationBean