Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
EvoticTalend
Contributor
Contributor

Can we get a column in Talend depends on the name of an Excel file?

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?

Labels (3)
3 Replies
gjeremy1617088143

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

EvoticTalend
Contributor
Contributor
Author

Thanks for your response gjeremy. But, How can i get the file name?

gjeremy1617088143

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