dynamic write file name in tFileOutputDelimited

One Star

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,
One Star

Re: dynamic write file name in tFileOutputDelimited

Hi
Please use tJavaRow instead of tjava.
Regards,
Pedro
One Star

Re: dynamic write file name in tFileOutputDelimited

I tried to use jJavaRow. I still got the test1_null.csv file.
One Star

Re: dynamic write file name in tFileOutputDelimited

Hi
The expression should be like this.
context.fileName=input_row.dateTime;
Regards,
Pedro
One Star

Re: dynamic write file name in tFileOutputDelimited

I did have the same code. but the file name is still test1_null.csv.
One Star

Re: dynamic write file name in tFileOutputDelimited

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
Seven Stars

Re: dynamic write file name in tFileOutputDelimited

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.
One Star

Re: dynamic write file name in tFileOutputDelimited

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?
One Star

Re: dynamic write file name in tFileOutputDelimited

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.
Five Stars

Re: dynamic write file name in tFileOutputDelimited

use a flow to iterate & tfixed flow as shown in the pic, your prob with null is solved Smiley Happy
One Star

Re: dynamic write file name in tFileOutputDelimited

The same problem is coming for me too. Not able to include a dynamic name for tFileOutputRaw.