我正在获取CSV文件作为输入,并希望转换为XML格式。当我在输入的csv文件中没有几个空的csv行或记录时,它正在创建空的xml记录。如何忽略要处理的空记录和/或在输出xml文件中创建的记录。
使用M子运行时4.2.1
CSV输入:
Type,AdminAlias,OriginatorID,OriginatorName,TransactionCode,TotalPaymentAmount,TotalClaimsCount,CreatedDateTime,FileDateTime,SourceDocumentType,ReceivedFileName,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
HEADER,GPS,,,,,,2020-04-02T10:55:56,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Type,ActionCode,Status,StatusMessage,RecipientName,ClaimPayeeType,LH1ParticipantUniqueID,ParticipantExternalId,ParticipantEmployeeNumber,FirstName,MiddleName,LastName,SSN,DOB,ProviderID,ProviderName,AddressLine1,AddressLine2,AddressLine3,AddressLine4,City,StateCode,ZipCode,CountryCode,ExternalClaimNumber,ClaimAmount,Claim Type,PaidDate,ReceiptReceived,ClaimOnHold,ServiceStartDate,ServiceEndDate,ExpenseCategory,ExpenseType,ServiceCode,ServiceCodeType,ClaimDescription,KeyName,KeyValue,,,,,,,,,,,,,,,,
CLAIM,I,P,,,,,,,DONALD,,HUGHES,123456789,1990-12-02,123456789,ASSOCIATED OMS AND IMPLANT CEN,,,,,,,,,22007635202,52.80,,,TRUE,FALSE,2000-03-06,2000-03-06,Medical Expenses,Other Medical,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
DataWeave脚本:
%dw 2.0
output application/xml skipNullOn="everywhere"
ns ns0 http://www.lighthouse1.com/LH1OnDemand/ClaimsExchange/2008/10/01/ //writeDeclaration = false //skipNullOn = "elements"
---
{
ns0#LH1StandardClaimsExchange @(TotalPaymentAmount: sum(payload.bodyRecords.ClaimAmount filter ($!="")), AdminAlias: payload.header.AdminAlias , TotalClaimsCount: sizeOf(payload.bodyRecords.ClaimAmount) as String , CreatedDateTime: payload.header.CreatedDateTime): {
(payload.bodyRecords filter ($ !=null and $ !='') map ((bodyRecord , indexOfBodyRecord) -> {
Claim @(Status: bodyRecord.Status , ActionCode: bodyRecord.ActionCode): {
Participant @(FirstName: bodyRecord.FirstName , LastName: bodyRecord.LastName , SSN: bodyRecord.SSN as String , DOB: bodyRecord.DOB as String): '',
Provider @(ProviderID: bodyRecord.ProviderID , ProviderName: bodyRecord.ProviderName): {
MailingAddress @(AddressLine1: bodyRecord.AddressLine1 , City: bodyRecord.City , StateCode: bodyRecord.StateCode , ZipCode: bodyRecord.ZipCode , CountryCode: bodyRecord.CountryCode): ''
},
ClaimDetail @(ExternalClaimNumber: bodyRecord.ExternalClaimNumber , ClaimAmount: bodyRecord.ClaimAmount , ReceiptReceived: bodyRecord.ReceiptReceived as String , ClaimOnHold: bodyRecord.ClaimOnHold as String , ServiceStartDate: bodyRecord.ServiceStartDate as String , ServiceEndDate: bodyRecord.ServiceEndDate as String , ExpenseCategory: bodyRecord.ExpenseCategory , ExpenseType: bodyRecord.ExpenseType): ''
}
}))
}
}
CSV输入
XML输出