One Star

Get filename from tfileinputexcel

Hello.
I have a tfileinputexcel component and I see the variable that contains the filename is called FILENAME
I use ((String)globalMap.get("tFileInputExcel_1_FILENAME")) in a field in tmap component but it doesnt work.
Any help?
6 REPLIES
Moderator

Re: Get filename from tfileinputexcel

Hi,
Please show us your job screenshots so that we can see if there is issue in it.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Get filename from tfileinputexcel

I think there's no need for screenshots, it's very simple, i'll explain better:
tFileInputExcel_1 ------> tmap -------> tlogrow
My excel file has 5 columns, so in tmap I put that 5 columns in an output as 5 different fields, but I want to be 6 fields instead 5, and in the 6th field (string type) I want to put the excel filename so I tried with ((String)globalMap.get("tFileInputExcel_1_FILENAME")) but it didn't work
Thanks for the help
Moderator

Re: Get filename from tfileinputexcel

Hi,
Yes it is simple workflow. I have design a demo job but didn't find ((String)globalMap.get("tFileInputExcel_1_FILENAME")) instead ((String)globalMap.get("tFileInputExcel_1_CURRENT_SHEET")).
See my screenshots
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Get filename from tfileinputexcel

Yes, but current_sheet isn't what I need...
Look at the image below, in english it means "Attached variable for this parameter is: __FILENAME__" , How can I use it? Or is it something different from what I think?
Thanks.
Moderator

Re: Get filename from tfileinputexcel

Hi,
There is no a global variable about file name for tFileInputExcel, you can press ctrl blank space to open the list of the global variables and see which global variables are available.
In this case, you define a context variable (eg: call it as filename) in the job, and set the file name of tFileInputExcel with context variable, for example: "D:/file/" context.filename, and then you are able to add a new column on tMap and set its value as context.filename.
Please see the online document How to centralize contexts and variables the section"How to use variables in a Job".
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: Get filename from tFileList

Hi,

I am getting such filename ~$Bank_ExcelFile.xlsx when I fetch with 

context.filename = ((String)globalMap.get("tFileList_1_CURRENT_FILE"));

I don't need ~$   garbage value.

Can you give me any suggestion on this?

 

Thanks,