Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Converting CSV (that has single and multivalue attributes) to XML

I have a csv file that has an attribute column as shown below. The data in that column is the name of the attributes. Some of the attributes could have multiple values. I want to convert this csv into a XML file which will have multivalue tag (listing all values) for the attributes that have more than one value. I know how to convert if there is only single value for each attribute. But I am not sure how to convert the csv to xml when the attributes have single and multivalues. Could somebody please help me with this? Thanks

Input CSV:

Attribute Name, Color
aab, red
abc, red
abc, green
abc, blue
xyz, white
xyz, purple
zyx, green

 

Expected Output:

<Value AttributeID="aab">red</Value>

<MultiValue AttributeID="abc">
<Value>red</Value>
<Value>green</Value>
<Value>blue</Value>
</MultiValue>
<MultiValue AttributeID="xyz">
<Value>white</Value>
<Value>purple</Value>
</MultiValue>
<Value AttributeID="zyx">green</Value>

Labels (4)
2 Replies
Anonymous
Not applicable
Author

 

Hi 

 

Try this with  tFileInputDelimited---> tFileOutputXml  0683p000009MACn.png

 

 

You can group the colors based on attribute name..

 

I got like this...

 

0683p000009Lrmd.png0683p000009Lrn6.png0683p000009LrdI.png

 

Anonymous
Not applicable
Author

Hi Vignesh, thanks for your response. 

My requirement is, the output XML has to be in the following format:

<Value AttributeID="aab">red</Value>

<MultiValue AttributeID="abc">
<Value>red</Value>
<Value>green</Value>
<Value>blue</Value>
</MultiValue>
<MultiValue AttributeID="xyz">
<Value>white</Value>
<Value>purple</Value>
</MultiValue>
<Value AttributeID="zyx">green</Value>