Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

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?
Labels (2)
9 Replies
Anonymous
Not applicable

Hi,
Please show us your job screenshots so that we can see if there is issue in it.
Best regards
Sabrina
Anonymous
Not applicable

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
Anonymous
Not applicable

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
0683p000009MBOC.png 0683p000009MBQ7.png 0683p000009MBQC.png
Anonymous
Not applicable

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.
0683p000009MBQH.jpg
Anonymous
Not applicable

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
Anonymous
Not applicable

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,

Anonymous
Not applicable

Shame on you guys from Talend Community. You just can´t even suggest some for a simple problem.

manodwhb
Champion II
Champion II

@dtsleite, What is your problem? Can you share your issue?

wow0609
Contributor II
Contributor II

It is over 10 years since this was posted, but I did want to make a comment, in case others come here.

 

Excel has some features to support 'unsaved' changes.  When accessing an Excel file in this state, Excel 'creates' a fake document, prefixed with the ~$ characters.  It isn't a real file.  I have had to put code in certain processes to IGNORE any files that start with ~$.  It is especially problematic since we process a lot of Excel files created by end-users.  We often get versions of the file that include this ~$Filename.xlsx.

Just ignore them, only process Excel files that do not start with it.

 

Hope this helps someone!