0

我有一个以逗号分隔的源平面文件,文件的标题带有 start date 和 end date ,下一行包含所有文件名,并继续源文件的数据示例:

"2015-05-09","2015-06-05"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
"CARRIER ","CONTRACT          ","ELGBL/GRP         ","                  ","TOTAL FEES","TOTAL FEES     ","PMPM ACA    ","PMPM ACA    ","RETAIL      ","RETAIL      ","MEDICAID    ","MEDICAID    ","STATE    ","STATE    ","MAIL SERVICE","MAIL SERVICE","RETAIL      ","RETAIL      ","POSTAGE -   ","POSTAGE -   ","SYSTEM      ","SYSTEM      ","SYSTEM      ","SYSTEM      ","SYSTEM      ","SYSTEM      ","SYSTEM      ","SYSTEM      ","SYSTEM      ","SYSTEM      ","SYSTEM      ","SYSTEM      ","SYSTEM      ","SYSTEM      ","SYSTEM      ","SYSTEM      ","OTHER       ","OTHER       ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","          
"        ","                  ","                  ","                  ","COUNT     ","AMOUNT         ","METAL       ","METAL       ","DIRECTS     ","DIRECTS     ","            ","            ","HEALTH      ","HEALTH      ","CLAIMS      ","CLAIMS      ","PHARMACY    ","PHARMACY    ","BULK        ","BULK        ","MCRCF       ","MCRCF       ","MCRCP       ","MCRCP       ","MPA         ","MPA         ","MRXC        ","MRXC        ","PPACA       ","PPACA       ","QPC         ","QPC         ","RXSEL       ","RXSEL       ","SPCR        ","SPCR        ","COUNT       ","AMOUNT      ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","          
"        ","                  ","                  ","                  ","          ","               ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","COUNT       ","AMOUNT      ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","            ","          
"1234    ","ABCD5678          ","ABCOEFITEST1      ","                  ","         1","           1.60","       1","           1.60","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       
"1234    ","ABCD5678          ","ABC200074002      ","                  ","         6","           3.20","       2","           3.20","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       4","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       
"1234    ","ABCD5678          ","ABC200178002      ","                  ","         2","           1.60","       1","           1.60","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       1","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       
"1234    ","ABCD5678          ","ABC200197001      ","                  ","         1","           1.60","       1","           1.60","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       
"1234    ","ABCD5678          ","ABC200204002      ","                  ","         2","           3.20","       2","           3.20","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       
"1234    ","ABCD5678          ","ABC200204003      ","                  ","         2","           3.20","       2","           3.20","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       
"1234    ","ABCD5678          ","ABC200232002      ","                  ","         4","           1.60","       1","           1.60","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       3","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       
"1234    ","ABCD5678          ","ABC200300001      ","                  ","         7","           1.60","       1","           1.60","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       6","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       
"1234    ","ABCD5678          ","ABC200345002      ","                  ","         1","           1.60","       1","           1.60","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       
"1234    ","ABCD5678          ","ABC200414001      ","                  ","         9","           3.20","       2","           3.20","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       7","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       
"1234    ","ABCD5678          ","ABC200491003      ","                  ","         1","           1.60","       1","           1.60","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","       0","           0.00","  

所以现在我将它作为一个精度为 1000 的长字符串读取,然后我想使用 Java 转换并将它们与分布在多个标题中的列名拆分,并将它们与下面的值相关联。一个输入行将登陆尽可能多的目标行。

第一件事:将文件逐行读入一个长字符串端口。

将“CurrentlyProcessedFileName”端口添加到源以捕获文件名。
计算读取的行数

用逗号分隔行 - 我该如何实现?猜测表达式或java转换以及java中的以下整个过程或者我可以使用SP,但是我如何用逗号分割行?

   If Current RowNumber = 1 Then    
        vINVC_BGN_DT := field1
        vINVC_END_DT := field2

   If Current RowNumber > 1
      If field1 != $$CARRIER Then
    NAME1 := NAME1 || field1  #Initialize NAME variables to an empty string
    NAME2 := NAME2 || field2
    NAME3 := NAME3 || field3  #repeat for each comma seperated field
      If field1 = $$CARRIER Then
    VALUE1 := field1
    VALUE2 := field2
    VALUE3 := field3          #repeat for each comma seperated field

对于每个源行,输出行数应等于不同 Amount_types 的计数,(不包括空行)

   For i in NAME4.NAMEx loop
       if NAMEi is not spaces or null then generate row
           target.INVC_TYPE = "CLAIM"
           target.FILE_RECEIPT_SK
           target.CARRIER := VALUE1
           target.CNTRCT := VALUE2
           target.PBM_GROUP := VALUE3
           target.INVC_BGN_DT := vINVC_BGN_DT  #From row1
           target.INVC_END_DT := vINVC_END_DT  #From row1
           target.INVC_AMOUNT_TYPE := NAMEi
           target.INVC_AMOUNT := VALUEi
   end i loop..
4

1 回答 1

0

您可以使用规范器将一行拆分为多行。在您的情况下,您必须分别处理第一行、接下来的 3 个标题行和数据行。为此,使用变量在表达式中创建一个序列号。

您可以在表达式本身中获取开始日期和结束日期:例如。

begin_date:= iif(seq=1, field1, begin_date)

要分隔标题行和数据行,请使用带有条件的 rouerseq>1 && seq<=4seq>4

现在您可以使用规范器将行拆分为多行。对于数据行,为运营商、合同、pbm_group、计数和金额创建 5 列,并将计数和金额的出现设置为总数。或计数或金额列。

您可以类似地对标题列使用另一个规范化器。最后使用连接器转换连接两个流。

您还可以使用 java 转换,在输入行选项卡中,您已经编写了类似的逻辑。要拆分行,您可以使用 split 方法。前任:

String[] fields=row.split(",");

现在数组fields将包含所有字段作为数组元素。您可以将适当的元素分配给输出端口并调用 Informatica 的generateRow()方法来创建目标记录。

于 2016-04-26T17:39:23.147 回答