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

Iterating over output files when they aren't a stream [v5.0.1]

I have the feeling this is possible, but the solution seems to be eluding me.
I would like to iterate over a set of input files, and transform them into output files with different data. The iterating over the input is easy; a tFileList followed by a tFileInputDelimited, using the stream global variable for the filename. Then a flow of the transforms I want. Now I get to the sticky part.
Ideally, I would like the output to go to a file of the same name, but with a different extension, and morphed into a different format. So, if I have a directory of .CSV files like this:
one.csv
two.csv
I want to read each one, perform a transform, and then create new versions of the file in JSON format. So I would then see this in the directory:
one.csv
two.csv
one.json
two.json
The tFileOutputJSON doesn't allow streams, and I can't use a global variable for a filename.
I tossed around using the tFlowToIterate, but no, that doesn't do it.
What would be the best solution path for this kind of scenario?
thanks!
Bruce
Labels (3)
5 Replies
Anonymous
Not applicable
Author

Hi Bruce,
I would do the follow:
tFileList (*.csv wildcard) --- iterate ---> tFileInputDelimited (filename dynamic based on the tFileList) --- main ---> tFileOutputJSON
I don't see any reason for the above not to work.
The tFileList automatically returns a set of values (Current File Name, Current File Path...) that you can use in the next components.
Anonymous
Not applicable
Author

The tFileList automatically returns a set of values (Current File Name, Current File Path...) that you can use in the next components.

Thanks for the reply. That's exactly what I would assume too, but tFileOutputJSON requires a static output file name. In other words, I don't see any way to use the variables that are passed down. Am I missing something obvious?
Every time I try to dynamically set the output filename in that component, it barfs and wants a static filename.
thanks,
bruce
Anonymous
Not applicable
Author

Hi Bruce,
Could you do a screenshot of the tFileOutputJSON component properties tab, and one of the error you get?
We can do it 0683p000009MACn.png
Anonymous
Not applicable
Author

Hi Bruce,
Could you do a screenshot of the tFileOutputJSON component properties tab, and one of the error you get?
We can do it 0683p000009MACn.png

Okay, My Bad! You were right, it worked perfectly.
In the preparation of the screenshot, I had to go back in and try to recreate the previous error. In putting a variable into the tFileOutputJSON "file name" field, it worked this time! I may have gotten off-track in the process, encountered an error, and then assumed that this component didn't support the stream/iterative nature of the flow.
For completeness sake, this is what I put in there (and which now works):
((String)globalMap.get("tFileList_1_CURRENT_FILEDIRECTORY")) + "\\" + ((String)globalMap.get("tFileList_1_CURRENT_FILE")) + ".json"
Thanks for making me go back and check my work! 🙂
bruce
Anonymous
Not applicable
Author

No problem!