cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping header fields to items with context change

davef0823
Explorer
0 Kudos
199

Hi,

1. Consider the input flat file (csv):

field1,field2,field3,field4

field1,field2,field3,field4

2. The fields are read into the following input structure:

data[]

field1

field2

field3

field4

Consider the output:

data[]

header

field1

items[]

field2

field3

field4

Mapping: For every unique field1 string, I map field2, field3 and field4 to items. However, if field1 (in row 1 and row 2) is the same value, I need to suppress creating the second data[] node and instead add field2, field3 and field4 to a second item[] under the original field1 entry (see below).

data[]

header

field1 (from row 1 of flat file)

items[] (from row1 of flat file)

field2

field3

field4

items[] (from row 2 of flat file)

field2

field3

field4

I would really appreciate some assistance with this. Would I need to create a UDF?

Thanks,

Dave

Accepted Solutions (1)

Accepted Solutions (1)

khusal810
Active Participant

Hello David,

The below Mapping may help you for the same.

davef0823
Explorer
0 Kudos

Thanks Khusal, it worked! The issue I had was how I had initially suppressed the data[] node - which caused issues. Much appreciated!

khusal810
Active Participant
0 Kudos

Hello David,

Happy to help you😊.

Can you close this question with the right answer?

Answers (3)

Answers (3)

davef0823
Explorer
0 Kudos

Input structure

Output structure

I am able to suppress the duplicate data[] node when field1 repeats, but I still need to figure out how to include the item fields (field2, field3 and field3) from the suppressed 2nd data[] node into the first data[] node.

davef0823
Explorer
0 Kudos
PriyankaAnagani
Active Contributor
0 Kudos

Can you share the sample input XML and expected target XML.

--Priyanka