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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

dynamic write file name in tFileOutputDelimited

Hi,
I am working on dynamically write the file name in tFileOutputDelimited.
My design is as:
tFileInputDelimited-->tMap--row1-->tJava-->tFileOutputDelimited.
I want to write the file name in tFileOutputDelimited with:
"c:/test/test1_"+context.fileName+".csv"
In my tMap, I have the output:
row1.dateTime
row1.ID
row1.value
row1.input
row2.output
all row1.dateTime values are the same
In my tJava, I have the simple code:
context.fileName=row1.dateTime;
I want the output file of tFileOutputDelimited as:
test1_dateTime.csv with the contents of:
dateTime,ID,value,input,output
When using my design, I got the test1_null.csv. The contents of the file is correct.
I am wondering where is wrong.
Thanks,
Labels (3)
10 Replies
Anonymous
Not applicable
Author

Hi
Please use tJavaRow instead of tjava.
Regards,
Pedro
Anonymous
Not applicable
Author

I tried to use jJavaRow. I still got the test1_null.csv file.
Anonymous
Not applicable
Author

Hi
The expression should be like this.
context.fileName=input_row.dateTime;
Regards,
Pedro
Anonymous
Not applicable
Author

I did have the same code. but the file name is still test1_null.csv.
Anonymous
Not applicable
Author

Hi
Are you sure?
It's not row1. It's input_row.
If it still doesn't work, please send me an email and attach this job.
Regards,
Pedro
alevy
Specialist
Specialist

You cannot use flow values in the file name as the output file is created before the input file starts reading. You need a tFlowToIterate and tFixedFlowInput instead of tJavaRow to achieve this. Search the forum for many many posts on doing this.
Anonymous
Not applicable
Author

It is still not working. I can get the print out context.fileName in the tJavaRow.
The print out in tJavaRow is looked like:
context.fileName2012-07-16 23:00
context.fileName2012-07-16 23:00
context.fileName2012-07-16 23:00
context.fileName2012-07-16 23:00
context.fileName2012-07-16 23:00
context.fileName2012-07-16 23:00
context.fileName2012-07-16 23:00
context.fileName2012-07-16 23:00
In my tJavaRow, the codes are:
output_row.PSI = input_row.PSI;
output_row.Type = input_row.Type;
output_row.DateTime = input_row.DateTime;
output_row.Value = input_row.Value;
context.fileName=input_row.DateTime;
System.out.println("context.fileName"+context.fileName);
In my tFileOutputDelimited, I have the file name: "d:/test/test1_"+context.fileName+".csv"
From the print out, I can see the contextfileName is assigned in every row, which having 8 rows in this case. Is the contextfileName in the file name will be written 8 times?
Anonymous
Not applicable
Author

my context.fileName intial value is null. I changed the intial value to be "abc", I then get the test1_abc.csv file. It's looked like the context.fileName that is defined my Context hasn't been over-written my the tJavaRow. I am wondering if I have done something is not correct in the Context definition, or I need to do something else.
djugal
Contributor III
Contributor III

use a flow to iterate & tfixed flow as shown in the pic, your prob with null is solved 0683p000009MACn.png