Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Example, we have an Excel file "Sales_300621" , of the sales of 30 of June of 2021.
Can we have a Date column in a table that gets this date from a filename?
Hi,@Ivan R , you could do this :
TalendDate.parseDate("ddMMyy",(your String input).replaceAll("\\D",""))
then in the date pattern of the output schema you chose the pattern you want for you date.
replaceAll("\\D","") will supress all non digit characters of the string.
Send me Love and Kudos
Thanks for your response gjeremy. But, How can i get the file name?
you can use tFileList component:
https://help.talend.com/r/3ilJYtUm4GWYVMfmW0wiwg/V_EZBc8F7f2ztmxHojfDHw
don't worry if you have the extension in the filename: replaceAll("\\D","") will suppress it too
so you can do tFilelist --> iterate link --> towgenerator with a date field and this value for your date :
TalendDate.parseDate("ddMMyy",((String)globalMap.get("tFileList_1_CURRENT_FILE")).replaceAll("\\D",""))
and the pattern you want in the schema of trowgenerator.
((String)globalMap.get("tFileList_1_CURRENT_FILE")) is a variable created by the tFileList component for each file it found