Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
jain1
Contributor
Contributor

Getting empty file created for tFileJSOnoutput using global_variable for constructing file name.

Hi0683p000009M8oQ.png0683p000009M8oV.png

I have a question on the globalvariable. In my job I am using global variables to create filename. But I have seen that even if the result is going in the error flow, still creates empty files in the main flow highlighted in yellow below. Can you please let me know how it can happen.

 

Thanks,

Jain

Labels (3)
1 Reply
Anonymous
Not applicable

Hi
The tFileOutputXXX component always create the file in the beginning of the whole process of a subjob, there is an option 'don't create empty file' existing some file output component such as tFileOutputDelimited, but this option is not available yet. As a workaround, store the data into memory first, check the number of rows, if it is >, read the data from memory and write them to file.
eg:
....tJavaFlex_2-->tHashOutput
|runIf
tHashInput--main--tFileOutputJson

on tJavaRlex:
in the begin part, define a counter variable
int counter=;

in the main part:
counter++;

in the end part:
globalMap.put("counter",counter)

set the condition of runIf as:
(Integer)globalMap.get("counter")>

Hope it helps!

Regards
Shong