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!
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
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