【问题标题】:Skip row in genfromtxt跳过 genfromtxt 中的行
【发布时间】:2013-05-28 07:01:51
【问题描述】:

我有下表:

 2M00251602+5422547            7.180          9.000          2.200
#2M00255540+5749320            4.420          5.200          1.600
 2M00274401+5330504            4.400          6.800          2.700
 2M00331747+6327504            4.540          5.900          0.400
#2M00333033+7054422            4.350          6.700          0.700
 2M00350487+5953079            5.310          7.400          1.100

我想跳过带有标签的行。如何让 genfromtxt 跳过带有标签符号的行?

注意:标签不需要在那里。我只需要跳过用户指定的行。

我知道在 IDL 中的 READCOL 下可以执行 SKIPSTRING='#'。 genfromtxt 中有类似的东西吗?如果没有,我可以使用什么程序/包来读取这样的表格并跳过用户指定的行?

提前致谢!

【问题讨论】:

    标签: numpy genfromtxt


    【解决方案1】:

    使用np.genfromtxtcomments='#' 参数。

    来自文档:

    comments : str, optional
        The character used to indicate the start of a comment.
        All the characters occurring on a line after a comment are discarded
    

    【讨论】:

      猜你喜欢
      • 2013-11-29
      • 1970-01-01
      • 1970-01-01
      • 2019-01-01
      • 1970-01-01
      • 2015-01-19
      • 2015-08-20
      • 1970-01-01
      • 2011-02-04
      相关资源
      最近更新 更多