使用grep有效地清除多行的固定宽度文件

时间:2014-11-21 09:34:09

标签: r grep

我找到了一个类似的帖子,它基本上总结了我之前尝试实现的目标(编辑后)。 How to read multiline fwf format where row may or may not flow multiline。但是我有一些标题分为多行格式,跨越每个事务。

我试图通过链接回答的投票功能来抓住,但它逃脱了我。我认为正则表达式是使用这种类型的固定宽度文件的方法,特别是使用多行。

文件如下所示:

Book Date    Transaction Details                                                                                                                                                                                                       Amount
Value Date                                                                                 Running Balance
                                                      Opening Balance:                      xxxxxxxxxxxxxx
11.17.2014 Transaction Type:                OUTW.REMITTANCE                                    -146.000,00
11.17.2014 Customer Reference:              xxxxxxxxxxx 
          Bank Reference:                   xxxxxxxxxxx
          Details of Payment:               xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
                                            xxxxxxxxxxxxxx
                                            xxxxxxxxxxx                                       7.699.015,78
11.17.2014 Transaction Type:                xxxxxxxxxxx                                              -3,00
11.17.2014 Customer Reference:              xxxxxxxxxx 
          Bank Reference:                   xxxxxxxxxxxx
          Details of Payment:               xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
                                            xxxxxxxxxxxxxxxxxxxxxxx
                                            xxxxxxxxxx                                        7.699.012,78
11.17.2014 Transaction Type:                xxxxxxxxxx                                               -0,50
11.17.2014 Customer Reference:              xxxxxxxxxx 
          Bank Reference:                   xxxxxxxxxx
          Details of Payment:
                                            xxxxxxxxxxxx
                                            xxxxxxxxxxxx                                      7.699.012,28
11.17.2014 Transaction Type:                OUTGIRO PAY                                            -995,40
11.17.2014 Customer Reference:              xxxxxxxxxx 
          Bank Reference:                   xxxxxxxxxxx
          Details of Payment:
                                            xxxxxxxxxxx 
                                            xxxxxxxxxxxxxxxxxxxxxxx
                                            xxxxxxxxxx
                                            xxxxxxxxxx                                        7.698.016,88
11.17.2014 Transaction Type:                OUTGIRO PAY                                         -71.760,00
11.17.2014 Customer Reference:              xxxxxxxxxx 
          Bank Reference:                   xxxxxxxxxxxx
          Details of Payment:
                                            xxxxxxxxxxxxxxxxxxxxxxx 
                                            xxxxxxxxxxxxxxxx
                                            xxxxxxxxxx
                                            xxxxxxxxxx                                        7.626.256,88
11.17.2014 Transaction Type:                OUTGIRO PAY                                         -31.543,00
11.17.2014 Customer Reference:              xxxxxxxxxx
          Bank Reference:                   xxxxxxxxxxx
          Details of Payment:
                                            xxxxxxxxxxxxxxxxxx
                                            xxxxxxxxxxx
                                            xxxxxxxxxx
                                            xxxxxxxxxx                                        7.594.713,88
11.17.2014 Transaction Type:                OUTGIRO PAY                                          -3.600,00
11.17.2014 Customer Reference:              xxxxxxxxxx 
          Bank Reference:                   xxxxxxxxxx
          Details of Payment:
                                            xxxxxxxxxxxxxxxx 
                                            xxxxxxx
                                            xxxxxxxxxx
                                            xxxxxxxxxx                                        7.591.113,88
11.17.2014 Transaction Type:                OUTGIRO PAY                                          -3.800,00
11.17.2014 Customer Reference:              xxxxxxxxxx 
          Bank Reference:                   xxxxxxxxxx
          Details of Payment:
                                            xxxxxxxxxxxx 
                                            xxxxxxxxxxxxxxxxx 
                                            xxxxxxxxxx
                                            xxxxxxxxxx                                        7.587.313,88
11.17.2014 Transaction Type:                xxxxxxxxxx
11.17.2014 Customer Reference:

由于只有价值日期,我可以知道交易细节的细分是什么,但我还需要借方/贷方以显示最后一笔交易后的余额。

任何帮助将不胜感激。再次感谢!

此致

Sony Putra

0 个答案:

没有答案