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

Announcements
AWS Degraded - You may experience Community slowness, timeouts, or trouble accessing: LATEST HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

How to get file name

Hi,
I want to upload a csv file into sql server table. I need get the file name and use the file name in the job. The file name pattern is "nl_accounts_yyyy.csv". I want to exact the 'yyyy' and store it in table. how i can do that?
thanks!
Labels (2)
3 Replies
ytuzet
Creator
Creator

you can use a tfilelist for that, even if you iterate only on one file
put a tfilelist on your job plug iterations on on a tjavarow
in the tjavarow press <ctrl>+<space> it will propose a list of variables choose the one you want from tfilelist
Anonymous
Not applicable

Yang,
I would do the following.
tFileList --> tFixedFlowOutput --> tMssqlOutput
Following code in tFixedFlowedInput:
StringHandling.RIGHT(StringHandling.LEFT(((String)globalMap.get("tFileList_1_CURRENT_FILE")),StringHandling.LEN(((String)globalMap.get("tFileList_1_CURRENT_FILE")))-4),4)

If you want to load the file in your database and have the year in an extra column you can do the following:
tFileList --> tFileinputdelimited--> tMap --> tMssqlOutput
In the extra column in the output part of the tMap you can put the same code from the tfixedflowinput. Every record will then have the year of the file in an extra column.
See attached screenshots.
Regards
_AnonymousUser
Specialist III
Specialist III
Author

thanks for reply!