tFileOutputDelimited variable filename not working

Six Stars

tFileOutputDelimited variable filename not working

Hi 

 

I'm trying to set the filename of the tFileOutputDelimited with a variable, but this doesn't seem to work. 

 

Goal is to read an excel, which has got one or multiple lines per customer_po_no and then split it into a file per customer_po_no.

Therefor I have this job:


jobOverview.jpg

In the tJavaRow_1 I do: 

 

System.out.println("PO: " + input_row.CUSTOMER_PO_NO);

context.CUSTOMER_PO_NO = input_row.CUSTOMER_PO_NO;

 

and in tFileOutputDelimited_2 I set the filename as:

 

context.CUSTOMER_PO_NO + ".csv" 

 

I see the number being printed is the correct one, however the filename is null (blank)

 

any ideas ?

 

thanks and kind regards

Christoph


Accepted Solutions
Seven Stars

Re: tFileOutputDelimited variable filename not working

Oh sorry, I missed that.

You could do something like this - 

1) Use tFlowToIterate after  tMap.

2) Then join tJava using iterate flow.

3) Set the values of input row fields for tFileOutDelimited in tJava like - row2.<fieldname> = ((String)globalMap.get("output.<fieldname>"));

4) And filename you can fetch using ((String)globalMap.get("output.customer_po_no")) in tFileOutputDelimited component.

 

Please refer the attached screenshot for better clarity.

 

Best Regards,

Abhishek

 


All Replies
Seven Stars

Re: tFileOutputDelimited variable filename not working

Hi Christoph,

I think what you should do, you should use here OnComponentOk trigger on tJavaRow instead of using main row.

I suppose what's happening here is main flow is getting executed before the value is set to the context variable customer_po_no.

 

Best Regards,

Abhishek

 

Six Stars

Re: tFileOutputDelimited variable filename not working

hi Abhishek

 

thanks for the tip, but the tFileOutput requires a row input instead of an OnComponentOK, how should I overcome that ?

 

regards

Christoph

Seven Stars

Re: tFileOutputDelimited variable filename not working

Oh sorry, I missed that.

You could do something like this - 

1) Use tFlowToIterate after  tMap.

2) Then join tJava using iterate flow.

3) Set the values of input row fields for tFileOutDelimited in tJava like - row2.<fieldname> = ((String)globalMap.get("output.<fieldname>"));

4) And filename you can fetch using ((String)globalMap.get("output.customer_po_no")) in tFileOutputDelimited component.

 

Please refer the attached screenshot for better clarity.

 

Best Regards,

Abhishek

 

Six Stars

Re: tFileOutputDelimited variable filename not working

Thanks Abhishek, your tip got it working!

 

quite surprised though, I would expect that in a tJavaRow component, connected to the main row, the order of the execution should be sequential, and this would avoid the issue with the context variable not being filled in? where is my understanding wrong there, any idea ? 

Five Stars

FileNames

After constructing a Job with a Source and Target defined.   If for any reason I need to delete the object(Source or Target) within the Job and bring it in again.  I cannot name the Source or Target the same name given.... Seems like it stores it in memory but I cannot find where that is so I can remove it!?

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download