1

我有许多充满 sudo 表的文本文档,如下例所示。将表解析为哈希或数组之类的最佳方法是什么?

我是编写自定义算法还是那里有现有的库?

PLACE  NO.  NAME                    DIV    RANK  SWIM  TRANS RANK  BIKE   MPH   TRANS RANK   RUN   PACE  TIME    
===== ===== ======================= ===    ====  ====  ===== ==== ======= ===== ===== ====  ====== ===== ======= 
    1     1 Krige Schabort          PCHAL    3   22:40  1:08   25 1:14:15 20.2  2:25    1   26:24  4:24 2:06:49                
    2    12 Kevin Moats             M5559   11   24:41  0:46    1 1:06:01 22.7  0:44    9   42:50  7:09 2:15:00                
4

2 回答 2

3

你可能想试试slither

于 2011-09-20T02:38:15.717 回答
1

如果格式是长度固定的并且内部填充了空格,那该怎么办String#unpack

您可以查看http://ruby-doc.org/core/classes/String.html#M001112了解详情

于 2011-09-20T04:26:36.943 回答