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,
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.
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?
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.