Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I need to (1) make a copy of a file and (2) rename the copied file based on a variable that resides within the file. I have used the tFileCopy component to copy the file, and also managed to extract the variable from the file e.g. date within the file(report), but I am not sure how I could insert this extracted variable (date) into the tFileCopy component's Destination Filename field.
Desperately need guidance to this, thank you
If you have successfully extracted the value from the file you need to add to the file name then simply use the tContextLoad to load that value into a predefined context variable. You can use a tmap with 2 columns to set the context load it needs one column named "key" which should be your predefined context and the second column name is "value" and that equals the value from the file.
So at a high level steps
If you have multiple files to do this with you can put steps 2-7 in a subjob and use a tFileList to iterate over the the subjob.
you can even put a date stamp on the file as well so do something like filenameCTX + TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",TalendDate.getCurrentDate()) ".csv"
If you need screen shots let me know.
Hello,
Could you please elaborate your case with an example with input and expected output values?
Best regards
Sabrina
If you have successfully extracted the value from the file you need to add to the file name then simply use the tContextLoad to load that value into a predefined context variable. You can use a tmap with 2 columns to set the context load it needs one column named "key" which should be your predefined context and the second column name is "value" and that equals the value from the file.
So at a high level steps
If you have multiple files to do this with you can put steps 2-7 in a subjob and use a tFileList to iterate over the the subjob.
you can even put a date stamp on the file as well so do something like filenameCTX + TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",TalendDate.getCurrentDate()) ".csv"
If you need screen shots let me know.
Brilliant, thanks heaps for the solution.