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: 
_AnonymousUser
Specialist III
Specialist III

[resolved] Generate a dynamic file name for tFileOutputMSXML

Hi all.
I'm a newbie with Talend and I'm using a tFileOutpuMSXML to generate a XML file base on MySQL db filled from a list of files read from a folder (thanks to a tFileList).
I would like to generate a new XML file for each file found in tFileList. First I thought it will be possible to create a dynamic fileName for my MSXML output but it seem impossible (the fileName is generated at launch of th job, the solution would be to close the xml file, regenerate a new file name and reopen the file in a Java Row but I wasn't able to do it).
Is there a solution to create a new file with either a unique name for each file read by the FileList or dynamicaly set a file name for each of these files thanks to the manipulation I described but I wasn't able to do?
BR
Labels (4)
1 Solution

Accepted Solutions
_AnonymousUser
Specialist III
Specialist III
Author

As it seemed that nobody had an answer about my request, I had to find another solution... and I did. Here is what I've done:

I created a tSetGlobalVar called, e.g., "myVar"
In a tJavaRow, I create a string called "myFileName" which is the dynamic part of the file name
In the same tJavaRow, I added the following code:

globalMap.put("myVar", myFileName.concat(".xml"));


I set the following file name for my tFileOutpuMSXML output: "C:/Users/cyrilp/Desktop/OutPutXML.xml"
I created a tFileCopy linked to my tFileOutputMSXML element thanks to a OnComponentOK event
I set the following parameters to my tFileCopy :
              - File name: "C:/Users/cyrilp/Desktop/OutPutXML.xml"
              - Destination folder: whatever you want
              - Rename: enabled
              - Destination file: ((String)globalMap.get("myVar"))
              - Remove source file: enabled
Then, it did the work! 0683p000009MACn.png
I don't know if it's the best way to solve a similar problem or if it would be possible to apply this on any case but it worked for me.
BR

View solution in original post

2 Replies
_AnonymousUser
Specialist III
Specialist III
Author

As it seemed that nobody had an answer about my request, I had to find another solution... and I did. Here is what I've done:

I created a tSetGlobalVar called, e.g., "myVar"
In a tJavaRow, I create a string called "myFileName" which is the dynamic part of the file name
In the same tJavaRow, I added the following code:

globalMap.put("myVar", myFileName.concat(".xml"));


I set the following file name for my tFileOutpuMSXML output: "C:/Users/cyrilp/Desktop/OutPutXML.xml"
I created a tFileCopy linked to my tFileOutputMSXML element thanks to a OnComponentOK event
I set the following parameters to my tFileCopy :
              - File name: "C:/Users/cyrilp/Desktop/OutPutXML.xml"
              - Destination folder: whatever you want
              - Rename: enabled
              - Destination file: ((String)globalMap.get("myVar"))
              - Remove source file: enabled
Then, it did the work! 0683p000009MACn.png
I don't know if it's the best way to solve a similar problem or if it would be possible to apply this on any case but it worked for me.
BR
Anonymous
Not applicable

Hi BR,
Glad that you have found the solution on your own and thanks for posting the solution.
Thanks
Vaibhav