【问题标题】:How to find end of line or start of new line in progress openedge 4gl?如何在openge 4gl中找到行尾或新行的开始?
【发布时间】:2016-09-17 05:51:48
【问题描述】:

我有一个 .csv 文件,我需要根据行首或行尾来操作数据。如何找到每条线的起点?

【问题讨论】:

    标签: csv newline progress-4gl openedge 4gl


    【解决方案1】:

    当您已经逐行导入文件时最简单。

    DEFINE VARIABLE cLine AS CHARACTER NO-UNDO.
    
    INPUT FROM yourfile.csv .
    
    REPEAT:
        IMPORT UNFORMATTED cLine .
    
        // cLine contains exactly a single line
    END.
    

    如果数据更加一致,您甚至可以使用带有 DELIMITER 的 UNFORMATTED 的 IMPORT。

    【讨论】:

      【解决方案2】:

      如果它真的是 CSV,那么您可以非常高效地处理它:

      define variable inputItemList as character no-undo extent 128.
      define variable i as integer no-undo.
      
      input from value( "yourfile.csv" ).
      itemLoop: repeat:
        inputItemList = ?.
        import delimiter "," inputItemList.
        do i = 1 to 128:
          if inputItemList[i] = ? then
            next itemLoop.
           else
            do:
              /* do something useful with this item... */
            end.
        end.
      end.
      input close.
      

      “128”是任意数量的项目 - 如果您比我更了解您的数据,请选择不同的项目。

      如果数据不是所有的字符字段并且是一致的,那么您也可以在 IMPORT 语句中使用正确键入的字段。

      【讨论】:

        猜你喜欢
        • 2016-07-12
        • 1970-01-01
        • 2016-07-23
        • 2016-07-23
        • 2016-08-26
        • 2016-07-15
        • 1970-01-01
        • 2020-05-04
        • 1970-01-01
        相关资源
        最近更新 更多