Search code examples
talend

Using context variable with fix values


In my talend job I have a context variable named context.TempFolder.

Now while copying data from sql table to excel file I need to create an Excel file named export.excel (fixed name) in to the folder specified by the variable context.TempFolder.

How do I specify the 'File Name' of my tFileOutputExcel component?

Here value of a context variable TempFolder might change but I will always be creating Excel file by same name export.excel


Solution

  • You just need to concatenate the context.TempFolder with your output file name.

    So your file path for your tFileOutputExcel should look something like:

    context.TempFolder + "export.excel.xls"
    

    You can use vraiables and strings like this in a lot of places in Talend. To do something slightly more complicated, you might define the output file name in your job (so calculate it at run time) and then put that file name in the globalMap and then retrieve it when you output your file so you might end up with something like:

    context.OutputFolder + (String)globalMap.get("FileName") + ".xls"
    

    This is useful for date-time stamping files for example. Or maybe defining the file name by some sort of data in your input.