无法读取ascii文件

时间:2014-08-20 13:59:20

标签: python numpy

我有一个文本文件如下所示,我无法读取最后一列。如何知道分隔符?

data = np.genfromtxt(f,usecols=(5),delimiter=' ',dtype=float)
print data

文本文件名为f:

   22219355 02/21/2003 10:24:31.843 -65.033577  65.429672      25.193       26.985641
   22219355 02/21/2003 10:24:31.868 -65.035101  65.429033      25.546       26.987436
   22219355 02/21/2003 10:24:31.893 -65.036626  65.428389      25.647       26.989231
   22219355 02/21/2003 10:24:31.918 -65.038151  65.427740      25.866       26.991026
   22219360 02/21/2003 10:24:32.818 -65.092890  65.402383      25.807       27.053846
   22219360 02/21/2003 10:24:32.843 -65.094410  65.401728      25.969       27.055641
   22219360 02/21/2003 10:24:32.868 -65.095928  65.401061      25.225       27.057436
   22219360 02/21/2003 10:24:32.993 -65.103518  65.397543      25.378       27.066410
   22219360 02/21/2003 10:24:33.018 -65.105038  65.396803      25.123       27.068205
   22219360 02/21/2003 10:24:33.043 -65.106558  65.396053      25.422       27.070000
   22219365 02/21/2003 10:24:33.068 -65.108078  65.395293      24.673       27.070000
   22219365 02/21/2003 10:24:33.093 -65.109599  65.394527      24.832       27.071538
   22219365 02/21/2003 10:24:33.118 -65.111119  65.393755      24.594       27.073077
   22219365 02/21/2003 10:24:33.143 -65.112639  65.392980      25.090       27.074615
   22219365 02/21/2003 10:24:33.193 -65.115677  65.391423      24.711       27.077692

1 个答案:

答案 0 :(得分:3)

尝试使用delimiter=None

默认情况下,genfromtxt假定分隔符=无,表示该行沿着空格(包括制表符)分割,这可能符合您的需要