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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Split csv into many xml

Hello

I have a csv file and I need to create separate xml files for each row, name of each xml file should match to the value of some column in csv.

Sounds easy but I cannot figured out how to do it...

 

I've made following job and in tFileOutputXML component I selected "Split output in several files" and "Rows in each output file - 1":

 

0683p000009Lstg.jpg

 

I try to use "row1.columnName" as a file name in tFileOutputXML but it doesnt work - files named as null1.xml, null2.xml, etc. As I understad this is because Output component is initialized once at the beginning of the job, when no data read from csv yet.

 

How can I acheeve what I need?

Labels (1)
2 Replies
TRF
Champion II
Champion II

Hi, 

That's because output files are opened when subjob starts.

Use the following design:

 

tFileInputDelimited-->tFlowToIterate--iterate-->tFixedFlowInput-->tFileOutputXML

tFlowToIterate transform each field of the current row to a global variable.

The "iterate" connection trnasform the flow to an iteration (for simple, you may consider it like a separate subjob).

tFixedFlowInput start a new flow using the global variables to initialize the fields, like this:

0683p000009LsWy.png

This flow is pushed to tFileOutputXML where you can reuse the global which contained the file name like this:

 

"C:/Users/offic/Desktop/TestTalend/"+(String)globalMap.get("row57.newColumn")+".xml"

Hope this heps.

 

Anonymous
Not applicable
Author

Hi TRF

 

Thanks, thats works (I suspected something like this). But this solution has an inconvenience because I need to maintain not only the schema which I can put in repository, but also a tFixedFlowInput component mapping where I need to map each column to corresponding global value... This looks like a tautology - column1 = (String)globalMap.get("row1.column1"). And the same for all columns,  there are many....

 

Is there any solution for that?